Download
We distribute a PHP Archive (PHAR) that contains all required dependencies of PHP Reflect bundled in a single file.
Make it executable, and put it into your $PATH.
$ chmod +x phpreflect-3.0.1.phar
$ mv phpreflect-3.0.1.phar /usr/local/bin/phpreflect
$ phpreflect --version
You can also immediately use the PHAR after you have downloaded it.
$ wget http://bartlett.laurent-laville.org/get/phpreflect-3.0.1.phar
$ php phpreflect-3.0.1.phar --version
With both methods then you have this output :
phpReflect version 3.0.1
Other alternative installations are possible. Please refer to the documentation for details on how to do this.
Configuration
phpreflect.json{
"source-providers": [
{
"in": ". as current",
"name": "/\\.(php|inc|phtml)$/"
}
],
"plugins": [
],
"analysers": [
],
"services": [
]
}
Put it in your project’s folder. Alternative locations are possible. Please refer to the documentation for details on how to do this.
Structure
- source-providers
- this entry provide list of your data sources to parse.
- plugins
- this entry list all plugins added to the core base code of PHP Reflect.
- analysers
-
this entry list all analysers that may be used with the
analyser:runcommand. - services
- this entry list all services that may be used with this application.
Execution
With the Reflect source code, invoke the following command :
$ phpreflect analyser:run .
and you should obtain something like this :
Data Source Analysed
Directories 20
Files 73
Structure
Namespaces 20
Interfaces 8
Traits 0
Classes 65
Abstract Classes 6 (9.23%)
Concrete Classes 59 (90.77%)
Methods 295
Scope
Non-Static Methods 282 (95.59%)
Static Methods 13 (4.41%)
Visibility
Public Method 251 (85.08%)
Protected Method 34 (11.53%)
Private Method 10 (3.39%)
Functions 12
Named Functions 0 (0.00%)
Anonymous Functions 12 (100.00%)
Constants 22
Global Constants 0 (0.00%)
Magic Constants 3 (13.64%)
Class Constants 19 (86.36%)
Tests
Classes 0
Methods 0
Another analyser (loc) is also available, and can be combined or not with structure
the default analyser.
With the Reflect source code, invoke the following command :
$ phpreflect analyser:run . loc
and you should obtain something like this :
Data Source Analysed
Directories 20
Files 73
Size
Lines of Code (LOC) 3620
Comment Lines of Code (CLOC) 137 (3.78%)
Non-Comment Lines of Code (NCLOC) 3483 (96.22%)
Logical Lines of Code (LLOC) 1194 (32.98%)
Classes 1115 (93.38%)
Average Class Length 17
Average Method Length 3
Functions 79 (6.62%)
Average Function Length 6
Not in classes or functions 0 (0.00%)
Complexity
Cyclomatic Complexity / LLOC 0.51
Cyclomatic Complexity / Number of Methods 2.72
Summary
Let’s review what we’ve done :
-
downloaded the latest stable PHAR version.
-
prepared a minimalist JSON configuration file that is OPTIONAL to run Reflect commands.
-
executed your first parse on the Reflect data source.
Next
Choose your way depending of your skill level.