/** * Sets up the shared fixture. * * @return void */ public static function setUpBeforeClass() { self::$fixtures = __DIR__ . DIRECTORY_SEPARATOR . 'fixtures' . DIRECTORY_SEPARATOR; self::$analyserId = 'Bartlett\\CompatInfo\\Analyser\\CompatibilityAnalyser'; $client = new Client(); // request for a Bartlett\Reflect\Api\Analyser self::$api = $client->api('analyser'); }
/** * Tests function signatures with optional arguments * * @param string $fctname Function name that have optional arguments * @param string $extname Extension name that provide the $fctname * * @return void * @group reference * @large * @dataProvider functionProvider */ public function testGetFunctionsWithOptionalArguments($fctname, $extname) { $this->assertFileExists(self::$fixtures . $fctname . '.18881o.php', "{$extname}::{$fctname} function does not have test file for optional arguments"); $client = new Client(); // request for a Bartlett\Reflect\Api\Analyser $api = $client->api('analyser'); $dataSource = self::$fixtures . $fctname . '.18881o.php'; $analysers = array('compatibility'); // ... and get metrics $metrics = $api->run($dataSource, $analysers); $functions = $metrics[self::$analyserId]['functions']; // retrieves function's parameters $parameters = $functions[$fctname]['parameters']; // ... and max arguments count used $argc = $functions[$fctname]['arg.max']; // when no arguments provided (default signature) array_unshift($parameters, $functions[$fctname]['php.min']); $this->assertEquals($parameters[$argc], $functions[$fctname]['php.min'], 'Wrong version with optional arguments on ' . $fctname . ' function'); }
/** * Examples of Compatibility Analyser's run with filter applied on final results. * * @category PHP * @package PHP_CompatInfo * @author Laurent Laville <*****@*****.**> * @license http://www.opensource.org/licenses/bsd-license.php BSD License * @version Release: @package_version@ * @link http://php5.laurent-laville.org/compatinfo/ * @since Example available since Release 4.2.0 */ require_once dirname(__DIR__) . '/vendor/autoload.php'; use Bartlett\Reflect\Client; // creates an instance of client $client = new Client(); // request for a Bartlett\Reflect\Api\Analyser $api = $client->api('analyser'); // perform request, on a data source with default analyser $dataSource = dirname(__DIR__) . '/src'; $analysers = array('compatibility'); // filter rules on final results $closure = function ($data) { foreach ($data as $title => &$groups) { if (strpos($title, 'CompatibilityAnalyser') === false) { continue; } // looking into Compatibility Analyser metrics only foreach ($groups as $group => &$values) { if (!in_array($group, array('interfaces', 'traits', 'classes', 'functions', 'constants'))) { continue;
* `phpcompatinfo reference:show amqp` * `phpcompatinfo reference:show amqp --releases` * `phpcompatinfo reference:show amqp --classes --filter=YourFilters.php` * * @category PHP * @package PHP_CompatInfo * @author Laurent Laville <*****@*****.**> * @license http://www.opensource.org/licenses/bsd-license.php BSD License * @version Release: @package_version@ * @link http://php5.laurent-laville.org/compatinfo/ * @since Example available since Release 4.0.0-alpha3+1 */ require_once dirname(__DIR__) . '/vendor/autoload.php'; use Bartlett\Reflect\Client; // creates an instance of client $client = new Client(); // request for a Bartlett\CompatInfo\Api\Reference $api = $client->api('reference'); // summary $infos = $api->show('amqp'); // OR get releases only $infos = $api->show('amqp', false, true); // OR get classes only, filtered by a closure $closure = function ($data) { foreach ($data as $title => &$values) { foreach ($values as $key => $val) { switch ($title) { case 'classes': if (version_compare($val['ext.min'], '1.0.0', 'lt')) { unset($values[$key]); }