Source Provider
Data Source Identification
Basic or Complex Strategy to identify the Data Source.
Compare to version 2, Reflect 3 offers two simple strategies to identify the data source.
First, is to give the relative or absolute path to file or directory to parse (without limitation).
Second, is to specify options to customize parsing process, to the Symfony Finder Component.
Basic Strategy
With all SAPI, no JSON config file is required (as it was for Reflect 2). You have just to give the relative or absolute path to file or directory to parse.
It’s also possible to specify any archive (phar, zip, tar, tgz, gz, rar) as file source.
$ phpreflect analyser:run /absolute/path/to/source
$ phpreflect analyser:run ./relative/path/to/source
Complex Strategy
Still as it was with Reflect 2, you will need to configure your data source in a JSON file.
Syntax is closed to the Symfony Finder Component that is used to limit data source contents to parse.
{
"source-providers": [
{
"in": "phar:///var/dist/owncloud-7.0.2.tar as owncloud7",
"name": "*.php",
"exclude": ["3rdparty"]
}
],
"plugins": [
],
"analysers" : [
]
}
phar://
protocol in front of archive identification.owncloud7
to identify data source entry in the JSON config file,
rather than the full path phar:///var/dist/owncloud-7.0.2.tar
.{
"source-providers": [
{
"in": "/home/github/phing/ as phing2",
"path": ["bin", "classes"],
"exclude": ["test"],
"name": "*.php"
}
],
"plugins": [
],
"analysers" : [
]
}
Learn more about source providers.
Handle Results
Whatever SAPI you use, all metrics (for each analysers asked) are available at end of parse, in the same format.
With CLI, and Reflect source code, to get a structure report, you have to invoke the following command :
$ phpreflect analyser:run /home/github/php-reflect/src
With others SAPI, use example https://raw.githubusercontent.com/llaville/php-reflect/master/examples/api_analyser_run.php
and you should obtain something like this :
Data Source Analysed Directories 20 Files 72 Structure Namespaces 20 Interfaces 8 Traits 0 Classes 64 Abstract Classes 6 (9.38%) Concrete Classes 58 (90.62%) Methods 293 Scope Non-Static Methods 280 (95.56%) Static Methods 13 (4.44%) Visibility Public Method 250 (85.32%) Protected Method 34 (11.60%) Private Method 9 (3.07%) Functions 13 Named Functions 0 (0.00%) Anonymous Functions 13 (100.00%) Constants 22 Global Constants 0 (0.00%) Magic Constants 3 (13.64%) Class Constants 19 (86.36%) Tests Classes 0 Methods 0
This is the default render. But, if you want to compare with other SAPI,
activate the debug verbose mode (-vvv
) to get the raw response.
You should obtain something like this :
Array ( [files] => Array ( [0] => /home/github/php-reflect/src/Bartlett/Reflect/Analyser/AbstractAnalyser.php [1] => /home/github/php-reflect/src/Bartlett/Reflect/Analyser/AnalyserInterface.php [2] => /home/github/php-reflect/src/Bartlett/Reflect/Analyser/AnalyserManager.php [3] => /home/github/php-reflect/src/Bartlett/Reflect/Analyser/LocAnalyser.php [4] => /home/github/php-reflect/src/Bartlett/Reflect/Analyser/ReflectionAnalyser.php [5] => /home/github/php-reflect/src/Bartlett/Reflect/Analyser/StructureAnalyser.php [6] => /home/github/php-reflect/src/Bartlett/Reflect/Api/Analyser.php [7] => /home/github/php-reflect/src/Bartlett/Reflect/Api/BaseApi.php [8] => /home/github/php-reflect/src/Bartlett/Reflect/Api/Cache.php [9] => /home/github/php-reflect/src/Bartlett/Reflect/Api/Config.php [10] => /home/github/php-reflect/src/Bartlett/Reflect/Api/Diagnose.php [11] => /home/github/php-reflect/src/Bartlett/Reflect/Api/Diagram.php [12] => /home/github/php-reflect/src/Bartlett/Reflect/Api/Plugin.php [13] => /home/github/php-reflect/src/Bartlett/Reflect/Api/Reflection.php [14] => /home/github/php-reflect/src/Bartlett/Reflect/Api/V3/Analyser.php [15] => /home/github/php-reflect/src/Bartlett/Reflect/Api/V3/Cache.php [16] => /home/github/php-reflect/src/Bartlett/Reflect/Api/V3/Common.php [17] => /home/github/php-reflect/src/Bartlett/Reflect/Api/V3/Config.php [18] => /home/github/php-reflect/src/Bartlett/Reflect/Api/V3/Diagnose.php [19] => /home/github/php-reflect/src/Bartlett/Reflect/Api/V3/Diagram.php [20] => /home/github/php-reflect/src/Bartlett/Reflect/Api/V3/Plugin.php [21] => /home/github/php-reflect/src/Bartlett/Reflect/Api/V3/Reflection.php [22] => /home/github/php-reflect/src/Bartlett/Reflect/Client/ClientInterface.php [23] => /home/github/php-reflect/src/Bartlett/Reflect/Client/LocalClient.php [24] => /home/github/php-reflect/src/Bartlett/Reflect/Client.php [25] => /home/github/php-reflect/src/Bartlett/Reflect/Collection/ReflectionCollection.php [26] => /home/github/php-reflect/src/Bartlett/Reflect/Console/Application.php [27] => /home/github/php-reflect/src/Bartlett/Reflect/Console/Command.php [28] => /home/github/php-reflect/src/Bartlett/Reflect/Console/CommandFactory.php [29] => /home/github/php-reflect/src/Bartlett/Reflect/Console/Formatter/LocOutputFormatter.php [30] => /home/github/php-reflect/src/Bartlett/Reflect/Console/Formatter/OutputFormatter.php [31] => /home/github/php-reflect/src/Bartlett/Reflect/Console/Formatter/StructureOutputFormatter.php [32] => /home/github/php-reflect/src/Bartlett/Reflect/Environment.php [33] => /home/github/php-reflect/src/Bartlett/Reflect/Event/AbstractDispatcher.php [34] => /home/github/php-reflect/src/Bartlett/Reflect/Event/CacheAwareEventDispatcher.php [35] => /home/github/php-reflect/src/Bartlett/Reflect/Event/DispatcherInterface.php [36] => /home/github/php-reflect/src/Bartlett/Reflect/Events.php [37] => /home/github/php-reflect/src/Bartlett/Reflect/Exception/Exception.php [38] => /home/github/php-reflect/src/Bartlett/Reflect/Exception/ModelException.php [39] => /home/github/php-reflect/src/Bartlett/Reflect/Model/AbstractFunctionModel.php [40] => /home/github/php-reflect/src/Bartlett/Reflect/Model/AbstractModel.php [41] => /home/github/php-reflect/src/Bartlett/Reflect/Model/ClassModel.php [42] => /home/github/php-reflect/src/Bartlett/Reflect/Model/ConstantModel.php [43] => /home/github/php-reflect/src/Bartlett/Reflect/Model/FunctionModel.php [44] => /home/github/php-reflect/src/Bartlett/Reflect/Model/MethodModel.php [45] => /home/github/php-reflect/src/Bartlett/Reflect/Model/ParameterModel.php [46] => /home/github/php-reflect/src/Bartlett/Reflect/Model/PropertyModel.php [47] => /home/github/php-reflect/src/Bartlett/Reflect/Output/Analyser.php [48] => /home/github/php-reflect/src/Bartlett/Reflect/Output/Cache.php [49] => /home/github/php-reflect/src/Bartlett/Reflect/Output/Config.php [50] => /home/github/php-reflect/src/Bartlett/Reflect/Output/Diagnose.php [51] => /home/github/php-reflect/src/Bartlett/Reflect/Output/Diagram.php [52] => /home/github/php-reflect/src/Bartlett/Reflect/Output/Plugin.php [53] => /home/github/php-reflect/src/Bartlett/Reflect/Output/Reflection.php [54] => /home/github/php-reflect/src/Bartlett/Reflect/PhpParser/NodeProcessor.php [55] => /home/github/php-reflect/src/Bartlett/Reflect/PhpParser/NodeProcessorAbstract.php [56] => /home/github/php-reflect/src/Bartlett/Reflect/Plugin/Cache/CacheAdapterInterface.php [57] => /home/github/php-reflect/src/Bartlett/Reflect/Plugin/Cache/CacheStorageInterface.php [58] => /home/github/php-reflect/src/Bartlett/Reflect/Plugin/Cache/DefaultCacheStorage.php [59] => /home/github/php-reflect/src/Bartlett/Reflect/Plugin/Cache/DoctrineCacheAdapter.php [60] => /home/github/php-reflect/src/Bartlett/Reflect/Plugin/CachePlugin.php [61] => /home/github/php-reflect/src/Bartlett/Reflect/Plugin/Log/DefaultLogger.php [62] => /home/github/php-reflect/src/Bartlett/Reflect/Plugin/LogPlugin.php [63] => /home/github/php-reflect/src/Bartlett/Reflect/Plugin/Notifier/GrowlNotifier.php [64] => /home/github/php-reflect/src/Bartlett/Reflect/Plugin/Notifier/NotifierInterface.php [65] => /home/github/php-reflect/src/Bartlett/Reflect/Plugin/NotifierPlugin.php [66] => /home/github/php-reflect/src/Bartlett/Reflect/Plugin/PluginInterface.php [67] => /home/github/php-reflect/src/Bartlett/Reflect/Plugin/PluginManager.php [68] => /home/github/php-reflect/src/Bartlett/Reflect/Plugin/ProfilerPlugin.php [69] => /home/github/php-reflect/src/Bartlett/Reflect/Tokenizer/DefaultTokenizer.php [70] => /home/github/php-reflect/src/Bartlett/Reflect/Util/Timer.php [71] => /home/github/php-reflect/src/Bartlett/Reflect.php ) [Bartlett\Reflect\Analyser\StructureAnalyser] => Array ( [namespaces] => 20 [interfaces] => 8 [traits] => 0 [classes] => 64 [abstractClasses] => 6 [concreteClasses] => 58 [functions] => 13 [namedFunctions] => 0 [anonymousFunctions] => 13 [methods] => 293 [publicMethods] => 250 [protectedMethods] => 34 [privateMethods] => 9 [nonStaticMethods] => 280 [staticMethods] => 13 [constants] => 0 [classConstants] => 19 [globalConstants] => 0 [magicConstants] => 3 [testClasses] => 0 [testMethods] => 0 ) )
-
First entry in array is the list of parsed
files
-
Second entry in array is the
structure
analyser result
Each analyser as its own data structure and results, but you will always get the fully qualified class name that identify origin of analyser used.
structure
and loc
)$ phpreflect analyser:run /home/github/php-reflect/src structure loc
Raw response Array ( [files] => Array ( ... ) [Bartlett\Reflect\Analyser\StructureAnalyser] => Array ( ... ) Array ( [files] => Array ( [0] => /home/github/php-reflect/src/Bartlett/Reflect/Analyser/AbstractAnalyser.php [1] => /home/github/php-reflect/src/Bartlett/Reflect/Analyser/AnalyserInterface.php [2] => /home/github/php-reflect/src/Bartlett/Reflect/Analyser/AnalyserManager.php [3] => /home/github/php-reflect/src/Bartlett/Reflect/Analyser/LocAnalyser.php [4] => /home/github/php-reflect/src/Bartlett/Reflect/Analyser/ReflectionAnalyser.php [5] => /home/github/php-reflect/src/Bartlett/Reflect/Analyser/StructureAnalyser.php [6] => /home/github/php-reflect/src/Bartlett/Reflect/Api/Analyser.php [7] => /home/github/php-reflect/src/Bartlett/Reflect/Api/BaseApi.php [8] => /home/github/php-reflect/src/Bartlett/Reflect/Api/Cache.php [9] => /home/github/php-reflect/src/Bartlett/Reflect/Api/Config.php [10] => /home/github/php-reflect/src/Bartlett/Reflect/Api/Diagnose.php [11] => /home/github/php-reflect/src/Bartlett/Reflect/Api/Diagram.php [12] => /home/github/php-reflect/src/Bartlett/Reflect/Api/Plugin.php [13] => /home/github/php-reflect/src/Bartlett/Reflect/Api/Reflection.php [14] => /home/github/php-reflect/src/Bartlett/Reflect/Api/V3/Analyser.php [15] => /home/github/php-reflect/src/Bartlett/Reflect/Api/V3/Cache.php [16] => /home/github/php-reflect/src/Bartlett/Reflect/Api/V3/Common.php [17] => /home/github/php-reflect/src/Bartlett/Reflect/Api/V3/Config.php [18] => /home/github/php-reflect/src/Bartlett/Reflect/Api/V3/Diagnose.php [19] => /home/github/php-reflect/src/Bartlett/Reflect/Api/V3/Diagram.php [20] => /home/github/php-reflect/src/Bartlett/Reflect/Api/V3/Plugin.php [21] => /home/github/php-reflect/src/Bartlett/Reflect/Api/V3/Reflection.php [22] => /home/github/php-reflect/src/Bartlett/Reflect/Client/ClientInterface.php [23] => /home/github/php-reflect/src/Bartlett/Reflect/Client/LocalClient.php [24] => /home/github/php-reflect/src/Bartlett/Reflect/Client.php [25] => /home/github/php-reflect/src/Bartlett/Reflect/Collection/ReflectionCollection.php [26] => /home/github/php-reflect/src/Bartlett/Reflect/Console/Application.php [27] => /home/github/php-reflect/src/Bartlett/Reflect/Console/Command.php [28] => /home/github/php-reflect/src/Bartlett/Reflect/Console/CommandFactory.php [29] => /home/github/php-reflect/src/Bartlett/Reflect/Console/Formatter/LocOutputFormatter.php [30] => /home/github/php-reflect/src/Bartlett/Reflect/Console/Formatter/OutputFormatter.php [31] => /home/github/php-reflect/src/Bartlett/Reflect/Console/Formatter/StructureOutputFormatter.php [32] => /home/github/php-reflect/src/Bartlett/Reflect/Environment.php [33] => /home/github/php-reflect/src/Bartlett/Reflect/Event/AbstractDispatcher.php [34] => /home/github/php-reflect/src/Bartlett/Reflect/Event/CacheAwareEventDispatcher.php [35] => /home/github/php-reflect/src/Bartlett/Reflect/Event/DispatcherInterface.php [36] => /home/github/php-reflect/src/Bartlett/Reflect/Events.php [37] => /home/github/php-reflect/src/Bartlett/Reflect/Exception/Exception.php [38] => /home/github/php-reflect/src/Bartlett/Reflect/Exception/ModelException.php [39] => /home/github/php-reflect/src/Bartlett/Reflect/Model/AbstractFunctionModel.php [40] => /home/github/php-reflect/src/Bartlett/Reflect/Model/AbstractModel.php [41] => /home/github/php-reflect/src/Bartlett/Reflect/Model/ClassModel.php [42] => /home/github/php-reflect/src/Bartlett/Reflect/Model/ConstantModel.php [43] => /home/github/php-reflect/src/Bartlett/Reflect/Model/FunctionModel.php [44] => /home/github/php-reflect/src/Bartlett/Reflect/Model/MethodModel.php [45] => /home/github/php-reflect/src/Bartlett/Reflect/Model/ParameterModel.php [46] => /home/github/php-reflect/src/Bartlett/Reflect/Model/PropertyModel.php [47] => /home/github/php-reflect/src/Bartlett/Reflect/Output/Analyser.php [48] => /home/github/php-reflect/src/Bartlett/Reflect/Output/Cache.php [49] => /home/github/php-reflect/src/Bartlett/Reflect/Output/Config.php [50] => /home/github/php-reflect/src/Bartlett/Reflect/Output/Diagnose.php [51] => /home/github/php-reflect/src/Bartlett/Reflect/Output/Diagram.php [52] => /home/github/php-reflect/src/Bartlett/Reflect/Output/Plugin.php [53] => /home/github/php-reflect/src/Bartlett/Reflect/Output/Reflection.php [54] => /home/github/php-reflect/src/Bartlett/Reflect/PhpParser/NodeProcessor.php [55] => /home/github/php-reflect/src/Bartlett/Reflect/PhpParser/NodeProcessorAbstract.php [56] => /home/github/php-reflect/src/Bartlett/Reflect/Plugin/Cache/CacheAdapterInterface.php [57] => /home/github/php-reflect/src/Bartlett/Reflect/Plugin/Cache/CacheStorageInterface.php [58] => /home/github/php-reflect/src/Bartlett/Reflect/Plugin/Cache/DefaultCacheStorage.php [59] => /home/github/php-reflect/src/Bartlett/Reflect/Plugin/Cache/DoctrineCacheAdapter.php [60] => /home/github/php-reflect/src/Bartlett/Reflect/Plugin/CachePlugin.php [61] => /home/github/php-reflect/src/Bartlett/Reflect/Plugin/Log/DefaultLogger.php [62] => /home/github/php-reflect/src/Bartlett/Reflect/Plugin/LogPlugin.php [63] => /home/github/php-reflect/src/Bartlett/Reflect/Plugin/Notifier/GrowlNotifier.php [64] => /home/github/php-reflect/src/Bartlett/Reflect/Plugin/Notifier/NotifierInterface.php [65] => /home/github/php-reflect/src/Bartlett/Reflect/Plugin/NotifierPlugin.php [66] => /home/github/php-reflect/src/Bartlett/Reflect/Plugin/PluginInterface.php [67] => /home/github/php-reflect/src/Bartlett/Reflect/Plugin/PluginManager.php [68] => /home/github/php-reflect/src/Bartlett/Reflect/Plugin/ProfilerPlugin.php [69] => /home/github/php-reflect/src/Bartlett/Reflect/Tokenizer/DefaultTokenizer.php [70] => /home/github/php-reflect/src/Bartlett/Reflect/Util/Timer.php [71] => /home/github/php-reflect/src/Bartlett/Reflect.php ) [Bartlett\Reflect\Analyser\LocAnalyser] => Array ( [llocClasses] => 1116 [llocByNoc] => 0 [llocByNom] => 0 [llocFunctions] => 80 [llocByNof] => 0 [llocGlobal] => 0 [classes] => 64 [functions] => 13 [methods] => 321 [cloc] => 136 [eloc] => 3207 [lloc] => 1196 [wloc] => 378 [loc] => 3721 [ccn] => 656 [ccnMethods] => 602 ) ) )