Awesome
phpstats
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.
Table of Contents
What is supported?
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.
Code metrics
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.
Dependency graphs
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.
Relations between symbols
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.
Reachability of functions
See the documentation part for details.
Brief information about the project
See the documentation part for details.
About the project
PhpStats is © 2020-2020 by Petr Makhnev.
Contacts
Have any questions—welcome in telegram: @petr_makhnev.
Contributing
Feel free to contribute to this project. I am always glad to new people.
License
PhpStats is distributed by an MIT license.