phpReflect version 2.0.0 build b45be1d0d1b5a46253f9cda894dd7717f0a64abd
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.phar $ mv phpreflect.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.phar $ php phpreflect.phar --version
With both methods then you have this output :
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": [
{
"name": "Analyser",
"class": "Bartlett\\Reflect\\Plugin\\Analyser\\AnalyserPlugin"
}
],
"analysers" : [
{
"name": "Structure",
"class": "Bartlett\\Reflect\\Analyser\\StructureAnalyser"
}
]
}
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.
Like Reflect always needs a JSON file to run, Remi Collet shared a workaround solution exposed here that allows to run :
$ phpreflect analyser:run .
- plugins
-
this entry list all plugins added to the core base code of PHP Reflect.
Don’t forget to add at least this default content, else the
analyser:runandanalyser:listcommands wouldn’t be available. - analysers
-
this entry list all analysers that may be used with the
analyser:runcommand.Don’t miss it, else you could not run theanalyser:runcommand.
Execution
With a default phpreflect.json as detailed above, put in the src/ folder of the
Reflect source code, and invoke the following command :
$ phpreflect analyser:run .
and you should obtain something like this :
Data Source Analysed
Directories 16
Files 46
Structure
Namespaces 16
Interfaces 0
Traits 0
Classes 38
Abstract Classes 5 (13.16%)
Concrete Classes 33 (86.84%)
Methods 256
Scope
Non-Static Methods 251 (98.05%)
Static Methods 5 (1.95%)
Visibility
Public Method 232 (90.62%)
Protected Method 24 (9.38%)
Private Method 0 (0.00%)
Functions 5
Named Functions 0 (0.00%)
Anonymous Functions 5 (100.00%)
Constants 102
Global Constants 101 (99.02%)
Class Constants 1 (0.98%)
Summary
Let’s review what we’ve done :
-
downloaded the latest stable PHAR version.
-
prepared your JSON configuration file that is required to run Reflect commands.
-
executed your first parse on the Reflect data source.
Next
Choose your way depending of your skill level.