By default,
-
recursive
option is set tofalse
in CompatInfo 2.26, while the Finder recursively traverse directories in version 3.2 -
cacheDriver
option is set tofile
in CompatInfo 2.26, while version 3.2 did not added the cache plugin.
Application Programming Interface
By default,
recursive
option is set to false
in CompatInfo 2.26,
while the Finder recursively traverse directories in version 3.2
cacheDriver
option is set to file
in CompatInfo 2.26,
while version 3.2 did not added the cache plugin.
<?php
require_once 'Bartlett/PHP/CompatInfo/Autoload.php';
$source = '/path/to/source';
$options = array(
'cacheDriver' => 'null',
'recursive' => true
);
$compatinfo = new PHP_CompatInfo($options);
$compatinfo->parse($source);
<?php
require_once 'vendor/autoload.php';
use Bartlett\CompatInfo;
use Bartlett\Reflect\ProviderManager;
use Bartlett\Reflect\Provider\SymfonyFinderProvider;
use Symfony\Component\Finder\Finder;
$dirs = '/path/to/source';
$finder = new Finder();
$finder->files()
->name('*.php')
->in($dirs);
$provider = new SymfonyFinderProvider($finder);
$pm = new ProviderManager;
$pm->set('dataSourceIdent', $provider);
$compatinfo = new CompatInfo;
$compatinfo->setProviderManager($pm);
$compatinfo->parse();
<?php
require_once 'Bartlett/PHP/CompatInfo/Autoload.php';
$source = '/path/to/source';
$options = array(
'cacheDriver' => 'file',
'recursive' => true
);
$compatinfo = new PHP_CompatInfo($options);
$compatinfo->parse($source);
cacheDriver
option what is by default set to false.<?php
require_once 'vendor/autoload.php';
use Bartlett\CompatInfo;
use Bartlett\Reflect\ProviderManager;
use Bartlett\Reflect\Provider\SymfonyFinderProvider;
use Bartlett\Reflect\Plugin\Cache\CachePlugin;
use Bartlett\Reflect\Plugin\Cache\DefaultCacheStorage;
use Bartlett\Reflect\Cache\DoctrineCacheAdapter;
use Doctrine\Common\Cache\FilesystemCache;
use Symfony\Component\Finder\Finder;
$dirs = '/path/to/source';
$finder = new Finder();
$finder->files()
->name('*.php')
->in($dirs);
$provider = new SymfonyFinderProvider($finder);
$pm = new ProviderManager;
$pm->set('dataSourceIdent', $provider);
$backend = new FilesystemCache(sys_get_temp_dir() . '/phpcompatinfo');
$doctrineCache = new DoctrineCacheAdapter($backend);
$cache = new DefaultCacheStorage($doctrineCache);
$compatinfo = new CompatInfo;
$compatinfo->setProviderManager($pm);
$compatinfo->addPlugin( new CachePlugin($cache) );
$compatinfo->parse();
<?php
require_once 'Bartlett/PHP/CompatInfo/Autoload.php';
$source = '/path/to/source';
$options = array(
'cacheDriver' => 'null',
'recursive' => true
);
$fileListener = new PHP_CompatInfo_Listener_File();
$compatinfo = new PHP_CompatInfo($options);
$compatinfo->attach($fileListener);
$compatinfo->parse($source);
<?php
require_once 'vendor/autoload.php';
use Bartlett\CompatInfo;
use Bartlett\Reflect\ProviderManager;
use Bartlett\Reflect\Provider\SymfonyFinderProvider;
use Symfony\Component\Finder\Finder;
$dirs = '/path/to/source';
$finder = new Finder();
$finder->files()
->name('*.php')
->in($dirs);
$provider = new SymfonyFinderProvider($finder);
$pm = new ProviderManager;
$pm->set('dataSourceIdent', $provider);
$compatinfo = new CompatInfo;
$compatinfo->setProviderManager($pm);
$compatinfo->getEventDispatcher()->addListener(
'reflect.progress',
function (GenericEvent $e) {
printf(
'Parsing Data source "%s" in progress ... File "%s"' . PHP_EOL,
$e['source'],
$e['file']->getPathname()
);
}
);
$compatinfo->parse();
<?php
require_once 'Bartlett/PHP/CompatInfo/Autoload.php';
$source = '/path/to/source';
$options = array(
'cacheDriver' => 'null',
'recursive' => true
);
$compatinfo = new PHP_CompatInfo($options);
$compatinfo->parse($source);
$versions = $compatinfo->getVersions();
$classes = $compatinfo->getClasses();
$functions = $compatinfo->getFunctions();
$extensions = $compatinfo->getExtensions();
<?php
require_once 'vendor/autoload.php';
use Bartlett\CompatInfo;
use Bartlett\CompatInfo\Analyser;
use Bartlett\Reflect\ProviderManager;
use Bartlett\Reflect\Provider\SymfonyFinderProvider;
use Bartlett\Reflect\Plugin\Analyser\AnalyserPlugin;
use Symfony\Component\Finder\Finder;
$dirs = '/path/to/source';
$finder = new Finder();
$finder->files()
->name('*.php')
->in($dirs);
$provider = new SymfonyFinderProvider($finder);
$sourceId = 'dataSourceIdent';
$pm = new ProviderManager;
$pm->set($sourceId, $provider);
$compatinfo = new CompatInfo;
$compatinfo->setProviderManager($pm);
$compatinfo->addPlugin(
new AnalyserPlugin(
array(
new Analyser\SummaryAnalyser(),
)
)
);
$compatinfo->parse();
$metrics = $compatinfo->getMetrics();
$versions = $metrics[$sourceId]['sa.versions'];
$classes = $metrics[$sourceId]['sa.classes'];
$functions = $metrics[$sourceId]['sa.functions'];
$extensions = $metrics[$sourceId]['sa.extensions'];
sa.
prefix corresponds to class constant METRICS_PREFIX of SummaryAnalyser.