$stack
$stack :
HiddenCoupling is an analyser which checks and finds hidden coupling between types
How ? This analyser searches for method calls. Everytime there is a call of a method against an object ( $obj->getThing() ), it means an edge from an implementation vertex where the call is to a method signature vertex.
Since "$obj" does not come from nowhere, its type (class or interface) must be known by the class owning the implementation vertex. In other words : If there is an edge from an implementation to a method, there must be at least one another directed path between these two vertices (through the class vertex, through a parameter vertex, superclass etc...) If you can't figure why, I recommand you to read the digraph language I've defined in this intent.
If there is none, maybe it means a hidden coupling. I add the "maybe" because, it's hard to find the type of "$obj" in soft-typed language like PHP. That's why there can be false positive. But it's easier to check false positives than to search through all over the php files to find that kind of weakness in the code.
One another thing, since I cannot detect calls from "call_user_func" and other magic features of PHP like "$obj->$methodName()" or "new $className" there is a big limit of this static analyser.
Neverthesless I pretend this tool can find at least 50% of hidden coupling in poorly-coded classes and about 10% of false positive, from what I've seen.
searchPath(\Trismegiste\Mondrian\Graph\Vertex $src, \Trismegiste\Mondrian\Graph\Vertex $dst)
\Trismegiste\Mondrian\Graph\Vertex | $src | |
\Trismegiste\Mondrian\Graph\Vertex | $dst |
__construct(\Trismegiste\Mondrian\Graph\Graph $g)
Decorates the graph
\Trismegiste\Mondrian\Graph\Graph | $g |
addEdge(\Trismegiste\Mondrian\Graph\Vertex $source, \Trismegiste\Mondrian\Graph\Vertex $target)
Add a (un)directed edge if it does not already exist
\Trismegiste\Mondrian\Graph\Vertex | $source | |
\Trismegiste\Mondrian\Graph\Vertex | $target |
addVertex(\Trismegiste\Mondrian\Graph\Vertex $v)
Add a vertex to the graph without edge
\Trismegiste\Mondrian\Graph\Vertex | $v |
searchEdge(\Trismegiste\Mondrian\Graph\Vertex $source, \Trismegiste\Mondrian\Graph\Vertex $target) : \Trismegiste\Mondrian\Graph\Edge
Searches an existing (directed or not) edge between two vertices
\Trismegiste\Mondrian\Graph\Vertex | $source | |
\Trismegiste\Mondrian\Graph\Vertex | $target |
getSuccessor(\Trismegiste\Mondrian\Graph\Vertex $v) : null|array
Get successors of a vertex
\Trismegiste\Mondrian\Graph\Vertex | $v |
null if the vertex is not in this graph
or an array of vertices
getEdgeIterator(\Trismegiste\Mondrian\Graph\Vertex $v) : \Trismegiste\Mondrian\Graph\Iterator
Get an iterator on edges for one vertex
\Trismegiste\Mondrian\Graph\Vertex | $v |
createReducedGraph() : \Trismegiste\Mondrian\Graph\Graph
Generate a digraph reduced to the hidden coupled vertices
Since all vertices need to be scanned, go for the Floyd–Warshall algorithm http://en.wikipedia.org/wiki/Floyd%E2%80%93Warshall_algorithm in O(n³)
recursivSearchPath(\SplObjectStorage $step, \Trismegiste\Mondrian\Graph\Vertex $dst)
\SplObjectStorage | $step | |
\Trismegiste\Mondrian\Graph\Vertex | $dst |
findOwningClassVertex(\Trismegiste\Mondrian\Transform\Vertex\ImplVertex $impl)
\Trismegiste\Mondrian\Transform\Vertex\ImplVertex | $impl |
findDeclaringVertex(\Trismegiste\Mondrian\Transform\Vertex\MethodVertex $meth)
\Trismegiste\Mondrian\Transform\Vertex\MethodVertex | $meth |