Source Provider
Data Source Identification
Basic or Complex Strategy to identify the Data Source.
Compare to version 2, CompatInfo 4 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 CompatInfo 3). 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.
$ phpcompatinfo analyser:run /absolute/path/to/source
$ phpcompatinfo analyser:run ./relative/path/to/source
Complex Strategy
Still as it was with CompatInfo 3, 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 CompatInfo source code, to get a compatibility report, you have to invoke the following command :
$ phpcompatinfo analyser:run /home/github/php-compat-info/src
With others SAPI, use example https://raw.githubusercontent.com/llaville/php-compat-info/master/examples/api_analyser_run.php
and you should obtain something like this :
Data Source Analysed
Directories 11
Files 13
Extensions Analysis
Extension Matches REF EXT min/Max PHP min/Max PHP all
Core Core 4.0.0 5.3.0
PDO PDO 5.1.0 5.1.0
curl curl 4.0.2 4.0.2
intl intl 2.0.0b1 5.3.7
libxml libxml 5.1.0 5.1.0
openssl openssl 5.2.0 5.2.0
pcre pcre 4.0.0 4.0.0
spl spl 5.1.0 5.1.0
standard standard 4.0.0 4.0.0 5.3.2
Total [9] 5.3.7
Namespaces Analysis
Namespace Matches REF EXT min/Max PHP min/Max PHP all
+global Core 4.0.0
Bartlett\CompatInfo user 5.3.0
Bartlett\CompatInfo\Analyser user 5.3.0
Bartlett\CompatInfo\Api user 5.3.0 5.3.2
Bartlett\CompatInfo\Api\V3 user 5.3.0
Bartlett\CompatInfo\Collection user 5.3.0
Bartlett\CompatInfo\Console user 5.3.0
Bartlett\CompatInfo\Console\Formatter user 5.3.0
Bartlett\CompatInfo\Output user 5.3.0
Bartlett\CompatInfo\PhpParser user 5.3.0
Bartlett\CompatInfo\Reference user 5.3.0
Bartlett\CompatInfo\Util user 5.3.0
Total [12] 5.3.0 5.3.2
Interfaces Analysis
Interface Matches REF EXT min/Max PHP min/Max PHP all
Bartlett\CompatInfo\Reference\ReferenceInterface 1 user 5.3.0
Total [1] 5.3.0
No trait found
Classes Analysis
Class Matches REF EXT min/Max PHP min/Max PHP all
Bartlett\CompatInfo\Analyser\CompatibilityAnalyser user 5.3.0
Bartlett\CompatInfo\Api\Reference user 5.3.0 5.3.2
Bartlett\CompatInfo\Api\V3\Reference user 5.3.0
Bartlett\CompatInfo\Collection\ReferenceCollection 1 user 5.3.0
Bartlett\CompatInfo\Console\Application user 5.3.0
Bartlett\CompatInfo\Console\Formatter\CompatibilityOutputFormatter user 5.3.0
Bartlett\CompatInfo\Environment 4 user 5.3.0
Bartlett\CompatInfo\Output\Reference user 5.3.0
Bartlett\CompatInfo\PhpParser\ConditionalCodeNodeProcessor 1 user 5.3.0
Bartlett\CompatInfo\Reference\ExtensionFactory 2 user 5.3.0
Bartlett\CompatInfo\Reference\SqliteStorage 1 user 5.3.0
Bartlett\CompatInfo\Util\Version 10 user 5.3.0
U Bartlett\Reflect\Analyser\AbstractAnalyser 1 user 5.3.0
U Bartlett\Reflect\Api\BaseApi 1 user 5.3.0
U Bartlett\Reflect\Api\V3\Common 1 user 5.3.0
U Bartlett\Reflect\Console\Application 1 user 5.3.0
U Bartlett\Reflect\Console\Formatter\OutputFormatter 2 user 5.3.0
U Bartlett\Reflect\PhpParser\NodeProcessorAbstract 1 user 5.3.0
U Doctrine\Common\Collections\AbstractLazyCollection 1 user 5.3.0
U Doctrine\Common\Collections\ArrayCollection 1 user 5.3.0
PDO 2 PDO 5.1.0 5.1.0
U PhpParser\Node 21 user 5.3.0
U PhpParser\Node\Name 1 user 5.3.0
RuntimeException 1 spl 5.1.0 5.1.0
U Symfony\Component\Console\Helper\TableSeparator 3 user 5.3.0
U Symfony\Component\Console\Output\OutputInterface 4 user 5.3.0
parent 5 Core 5.0.0 5.0.0
self 11 Core 5.0.0 5.0.0
stdClass 1 Core 4.0.0 4.0.0
Total [29] 5.3.0 5.3.2
Functions Analysis
Function Matches REF EXT min/Max PHP min/Max
array_key_exists 7 standard 4.0.7 4.0.7
array_map 2 standard 4.0.6 4.0.6
array_merge 3 standard 4.0.0 4.0.0
array_pop 6 standard 4.0.0 4.0.0
array_shift 2 standard 4.0.0 4.0.0
array_slice 1 standard 4.0.0 4.0.0
array_values 1 standard 4.0.0 4.0.0
closure-73-75 user 5.3.0
copy 1 standard 4.0.0 4.0.0
count 14 standard 4.0.0 4.0.0
C curl_version 1 curl 4.0.2 4.0.2
defined 4 Core 4.0.0 4.0.0
dirname 3 standard 4.0.0 4.0.0
each 2 Core 4.0.0 4.0.0
end 3 standard 4.0.0 4.0.0
explode 2 standard 4.0.0 4.0.0
extension_loaded 1 Core 4.0.0 4.0.0
file_exists 2 standard 4.0.0 4.0.0
function_exists 1 Core 4.0.0 4.0.0
in_array 10 standard 4.0.0 4.0.0
is_array 1 standard 4.0.0 4.0.0
is_callable 1 standard 4.0.6 4.0.6
is_string 10 standard 4.0.0 4.0.0
ksort 3 standard 4.0.0 4.0.0
ltrim 1 standard 4.0.0 4.0.0
mkdir 1 standard 4.0.0 4.0.0
phpversion 2 standard 4.0.0 4.0.0
preg_match 2 pcre 4.0.0 4.0.0
sha1_file 2 standard 4.3.0 4.3.0
sprintf 26 standard 4.0.0 4.0.0
str_replace 1 standard 4.0.0 4.0.0
strcasecmp 4 Core 4.0.0 4.0.0
stream_resolve_include_path 1 standard 5.3.2 5.3.2
strpos 2 standard 4.0.0 4.0.0
strtolower 1 standard 4.0.0 4.0.0
substr 2 standard 4.0.0 4.0.0
sys_get_temp_dir 1 standard 5.2.1 5.2.1
ucfirst 5 standard 4.0.0 4.0.0
version_compare 9 standard 4.0.7 4.0.7
Total [39] 5.3.2
Constants Analysis
Constant Matches REF EXT min/Max PHP min/Max
C INTL_ICU_VERSION 2 intl 2.0.0b1 5.3.7
LIBXML_DOTTED_VERSION 1 libxml 5.1.0 5.1.0
LIBXML_VERSION 1 libxml 5.1.0 5.1.0
C OPENSSL_VERSION_NUMBER 1 openssl 5.2.0 5.2.0
C OPENSSL_VERSION_TEXT 1 openssl 5.2.0 5.2.0
PHP_EOL 5 Core 4.3.10 4.3.10
PHP_VERSION 4 Core 4.0.0 4.0.0
__DIR__ 1 Core 5.3.0 5.3.0
false 14 Core 4.0.0 4.0.0
null 15 Core 4.0.0 4.0.0
true 10 Core 4.0.0 4.0.0
Total [11] 5.3.0
Conditions Analysis
Condition Matches REF EXT min/Max PHP min/Max
defined(INTL_ICU_VERSION) 2 intl 2.0.0b1 5.3.7
defined(OPENSSL_VERSION_NUMBER) 1 openssl 5.2.0 5.2.0
defined(OPENSSL_VERSION_TEXT) 1 openssl 5.2.0 5.2.0
function_exists(curl_version) 1 curl 4.0.2 4.0.2
Total [4] 5.3.7
Requires PHP 5.3.2 (min), PHP 5.3.2 (all)
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 :
Raw response
Array
(
[files] => Array
(
[0] => /home/github/php-compat-info/src/Bartlett/CompatInfo/Reference/ExtensionFactory.php
[1] => /home/github/php-compat-info/src/Bartlett/CompatInfo/Api/V3/Reference.php
[2] => /home/github/php-compat-info/src/Bartlett/CompatInfo/Analyser/CompatibilityAnalyser.php
[3] => /home/github/php-compat-info/src/Bartlett/CompatInfo/Api/Reference.php
[4] => /home/github/php-compat-info/src/Bartlett/CompatInfo/Collection/ReferenceCollection.php
[5] => /home/github/php-compat-info/src/Bartlett/CompatInfo/Console/Application.php
[6] => /home/github/php-compat-info/src/Bartlett/CompatInfo/Console/Formatter/CompatibilityOutputFormatter.php
[7] => /home/github/php-compat-info/src/Bartlett/CompatInfo/Environment.php
[8] => /home/github/php-compat-info/src/Bartlett/CompatInfo/Output/Reference.php
[9] => /home/github/php-compat-info/src/Bartlett/CompatInfo/PhpParser/ConditionalCodeNodeProcessor.php
[10] => /home/github/php-compat-info/src/Bartlett/CompatInfo/Reference/ReferenceInterface.php
[11] => /home/github/php-compat-info/src/Bartlett/CompatInfo/Reference/SqliteStorage.php
[12] => /home/github/php-compat-info/src/Bartlett/CompatInfo/Util/Version.php
)
[Bartlett\CompatInfo\Analyser\CompatibilityAnalyser] => Array
(
[versions] => Array
(
[php.min] => 5.3.2
[php.max] =>
[php.all] => 5.3.2
)
[extensions] => Array
(
...
)
[namespaces] => Array
(
...
)
[interfaces] => Array
(
...
)
[traits] => Array
(
)
[classes] => Array
(
...
)
[methods] => Array
(
...
)
[functions] => Array
(
...
)
[constants] => Array
(
...
)
[conditions] => Array
(
...
)
)
)
-
First entry in array is the list of parsed
files -
Second entry in array is the
compatibilityanalyser 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 compatibility)$ phpcompatinfo analyser:run /home/github/php-compat-info/src structure compatibility
Raw response
Array
(
[files] => Array
(
...
)
[Bartlett\Reflect\Analyser\StructureAnalyser] => Array
(
...
)
[Bartlett\CompatInfo\Analyser\CompatibilityAnalyser] => Array
(
...
)
)