Comments (3)
@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.
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.
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)
- Add a PHAR HOT 3
- Unable to invoke "dot" to create image file HOT 1
- Hanging on writing to dependency graph file HOT 1
- @see tag is interpreted wrong HOT 3
- Multiple output formats for one analysis run
- phpda not taking relative paths to config file
- Is there way to ignore built-in functions? HOT 6
- Config File Name HOT 1
- can source in config be array? HOT 1
- Symfony 4? HOT 1
- PHP 7.1 Support HOT 2
- namespaceFilter plugin is never called on global namespace
- Packagist still on v1.3.1 - can you update it, or setup auto update HOT 2
- Question: Usage graph for single class HOT 1
- Is this a code analysis tool or a static analysis one? HOT 1
- Array union types aren't handled properly
- Write dependency graph is not working or is taking too much time HOT 1
- Syntax error thrown due to invalid subgraph groupid
- Composer package is no longer installable HOT 2
- Install fails in PHP 8.1 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from phpdependencyanalysis.