PHP Class Trismegiste\Mondrian\Analysis\HiddenCoupling

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.
Inheritance: extends Trismegiste\Mondrian\Graph\BreadthFirstSearch, implements Trismegiste\Mondrian\Analysis\Generator
显示文件 Open project: trismegiste/mondrian Class Usage Examples

Public Methods

Method Description
createReducedGraph ( ) Generate a digraph reduced to the hidden coupled vertices

Protected Methods

Method Description
findDeclaringVertex ( MethodVertex $meth )
findOwningClassVertex ( ImplVertex $impl )

Method Details

createReducedGraph() public method

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³)
public createReducedGraph ( )

findDeclaringVertex() protected method

protected findDeclaringVertex ( MethodVertex $meth )
$meth Trismegiste\Mondrian\Transform\Vertex\MethodVertex

findOwningClassVertex() protected method

protected findOwningClassVertex ( ImplVertex $impl )
$impl Trismegiste\Mondrian\Transform\Vertex\ImplVertex