Giter Club home page Giter Club logo

Comments (3)

bishopb avatar bishopb commented on May 28, 2024 1

@vintage-dreamer The configuration suggestion provided by @mamuz works in my case.

The following config shows all nodes connected to classes ending in "Peer", and uses a custom formatter to remove edgeless nodes in SVG output:

mode: 'usage'
source: 'path/to/source'
filePattern: '*.php'
formatter: 'GraphFormatter'
target: 'path/to/output/dependencies.svg'
visitorOptions:
  PhpDA\Parser\Visitor\Required\DeclaredNamespaceCollector: {minDepth: 1, sliceLength: 2}
  PhpDA\Parser\Visitor\Required\MetaNamespaceCollector: {minDepth: 1, sliceLength: 2, excludePattern: '/^(?!.*Peer).*$/'}
  PhpDA\Parser\Visitor\Required\UsedNamespaceCollector: {minDepth: 1, sliceLength: 2, excludePattern: '/^(?!.*Peer).*$/'}
<?php
use PhpDA\Writer\Strategy\StrategyInterface;
use PhpDA\Writer\Strategy\Svg;
use Fhaculty\Graph\Graph;

class GraphFormatter implements StrategyInterface
{
    public function filter(Graph $graph)
    {
        foreach ($graph->getVertices() as $vertex) {
            if (0 === count($vertex->getEdges())) {
                $vertex->destroy();
            }
        }

        $svg = new Svg();
        return $svg->filter($graph);
    }
}

from phpdependencyanalysis.

mamuz avatar mamuz commented on May 28, 2024

Hi @vintage-dreamer,

thx for your feedback.

This Tool is using at least three required visitors, which are configurable independently.
DeclaredNamespaceCollector is for fetching a namespace which can have dependencies.
MetaNamespaceCollector is for fetching possible dependecies by inheritence.
UsedNamespaceCollector is for fetching possible dependecies by call.

That means you have to use your negated exclude pattern only for MetaNamespaceCollector and UsedNamespaceCollector to meet your requirement.

For instance based on the standard configuration:

# ...
visitorOptions:
  PhpDA\Parser\Visitor\Required\DeclaredNamespaceCollector: {minDepth: 2, sliceLength: 2}
  PhpDA\Parser\Visitor\Required\MetaNamespaceCollector: {minDepth: 2, sliceLength: 2, excludePattern: '/^(?!.*AnalysedFoo).*$/'}
  PhpDA\Parser\Visitor\Required\UsedNamespaceCollector: {minDepth: 2, sliceLength: 2, excludePattern: '/^(?!.*AnalysedFoo).*$/'}
# ...

In this case you are getting your desired graph, but you will also have edgeless nodes which are not depended to AnalysedFoo. I think this solution is working for you, due the fact that edgeless nodes are not in focus.

from phpdependencyanalysis.

fankandin avatar fankandin commented on May 28, 2024

Thank you for your reach in content reply!
Unfortunately it doesn't seem to work. And I'm afraid it's pretty hard to provide a better example of my results. But maybe it would be more clear if show you this hack I applied to the method

\PhpDA\Layout\Builder::createEdgesFor():

    private function createEdgesFor(array $dependencies, array $edgeLayout, array $vertexLayout = array())
    {
        $dep = 'AnalysedFoo';
        foreach ($dependencies as $dependency) {
           if (
                (strpos($dependency->toString(), $dep) !== 0 && strpos($this->adtRootVertex->getId(), $dep) !== 0)
                || strpos($this->adtRootVertex->getId(), $dep) === 0
           ) {
               continue;
           }

with no exclusion patterns in the config. And this seems to help me a lot. The only problem left is edgeless nodes which are not removed with this hack. Does it ring you a bell, what exactly I did? 😄

from phpdependencyanalysis.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.