PhpStats is a tool that collects statistics for the code of your project and, based on these statistics, calculates various qualitative metrics of the code, builds the necessary graphs, and also finds the relationships between symbols in the system.
It tries to be fast, at the moment—about 150k lines of code per second on a MacBook Pro 2019 with Core i5.
The tool is built on top of NoVerify and written in Go.
Documentation for the project here.
PhpStats currently represents five areas:
- Collecting code metrics;
- Building dependency graphs;
- Analysis of relationships between symbols;
- Gathering brief information about the project;
- Analysis of the reachability of a function.
It also allows you to view lists of classes, interfaces, functions, methods, files and namespaces in a tabular form with the ability to sort by metrics.
Let's look at each point separately.
PhpStats currently calculates the following metrics:
- Afferent couplings:
- Efferent couplings:
- Instability:
- Abstractness;
- Lack of Cohesion in Methods;
- Lack of Cohesion in Methods 4 (or the number of connected components of the class);
- Cyclomatic Complexity;
- Count of magic numbers in functions and methods;
- Count fully typed methods.
See the documentation part for details.
PhpStats is currently building the following dependency graphs:
- Class (or interface) dependencies;
- Class (interface) extend or implementation dependencies;
- Function or method dependencies;
- Links within a class (or graph for the LCOM 4 metric);
- Links between files (included in global and in functions);
- Namespace dependencies graph;
- Namespace structure graph;
- Function reachability graph.
See the documentation part for details.
PhpStats is currently analyzing the following relations:
-
For class-class relations:
- Whether one class is extends another and vice versa;
- Whether the class implements the interface or vice versa;
- What methods, fields and constants are used by one class used by another and in which methods this happens.
-
For class-function relations:
- Function belong to class;
- The class is used inside the function;
- Used class members in functions;
- The function is used in the class (+ all methods where this function is used).
-
For function-function relations:
- Functions belong to the same class;
- Does the first function use the second and vice versa;
- Whether the first function is reachable from the second through calls and vice versa (+ call stacks to reach the function).
See the documentation part for details.
See the documentation part for details.
See the documentation part for details.
PhpStats is © 2020-2020 by Petr Makhnev.
Have any questions—welcome in telegram: @petr_makhnev.
Feel free to contribute to this project. I am always glad to new people.
PhpStats is distributed by an MIT license.