Take a look at your project from the inside with PhpStats
With PhpStats you can find places in the code that need improvement, as well as be able to consider how various symbols of your system are communicated in the form of graphs, and all this is incredibly fast (analysis of the entire Symfony project (about 600k lines of code) will take no more than 5 seconds from the second analysis).
Get started now View it on GitHub
Table of contents
Getting started
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.
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.
Dependency graphs
PhpStats is currently building the following dependency graphs:
- Class (or interface) dependencies;
- Class (interface) extend and 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.
Graphviz is used to build graphs.
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).
Brief information about the project
PhpStats is currently collecting various brief information about the project presented below:
General Test project statistics
Size
Lines of Code (LOC): 611240
Comment Lines of Code (CLOC): 109340 (17.89%)
Non-Comment Lines of Code (NCLOC): 501900 (82.11%)
Metrics
Cyclomatic Complexity
Average Complexity per Class: 5.55
Maximum Class Complexity: 29954.00
Minimum Class Complexity: 0.00
Average Complexity per Method: 1.01
Maximum Method Complexity: 142.00
Minimum Method Complexity: 0.00
Average Complexity per Functions: 0.00
Maximum Functions Complexity: 6.00
Minimum Functions Complexity: 0.00
Count of Magic Numbers
Average Class Count: 0
Maximum Class Count: 5055
Minimum Class Count: 2
Average Method Count: 0
Maximum Method Count: 50
Minimum Method Count: 0
Average Functions Count: 0
Maximum Method Count: 2
Minimum Method Count: 0
Structure
Files: 5323
Namespaces: 1680
Interfaces: 423
Traits 10
Classes 4974
Abstract Classes: 218 (4.04%)
Concrete Classes: 4756 (95.96%)
Methods: 29738
Constants: 1152
Functions:
Named Functions: 66 (3.32%)
Anonymous Functions: 1921 (96.68%)
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.