/** * Data Provider to test functions with default and optional arguments. * * @return array */ public function functionProvider() { $pdo = Environment::initRefDb(); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $stmt = $pdo->prepare('SELECT f.name, e.name as "ext.name" ' . ' FROM bartlett_compatinfo_functions f, bartlett_compatinfo_extensions e' . ' WHERE f.ext_name_fk = e.id AND f.parameters != "" '); $stmt->execute(); $functions = $stmt->fetchAll(PDO::FETCH_NUM); return $functions; }
/** * @covers Bartlett\CompatInfo\Environment::initRefDb * * @return void */ public function testInitRefDb() { try { $pdo = Environment::initRefDb(); } catch (\Exception $e) { $this->fail('An unexpected ' . get_class($e) . ' exception has been raised with message. ' . $e->getMessage()); } $this->assertInstanceOf('PDO', $pdo, 'Reference database instance is not PDO'); }
/** * List all references supported. * * @return array */ public function dir() { $pdo = Environment::initRefDb(); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $stmt = $pdo->query('SELECT e.name, rel_date as "date", rel_state as "state",' . ' rel_version as "ext.min", ext_max as "ext.max",' . ' php_min as "php.min", php_max as "php.max"' . ' FROM bartlett_compatinfo_releases r, bartlett_compatinfo_extensions e' . ' WHERE r.ext_name_fk = e.id' . ' ORDER BY e.name asc, date desc, rel_version desc'); $rows = array(); foreach ($stmt as $rec) { $key = strtolower($rec['name']); if (!empty($rec['date']) && !array_key_exists($key, $rows)) { $ref = new \stdClass(); $ref->name = $rec['name']; $ref->version = $rec['ext.min']; $ref->state = $rec['state']; $ref->date = $rec['date']; if (extension_loaded($ref->name)) { $version = phpversion($ref->name); $pattern = '/^[0-9]+\\.[0-9]+/'; if (!preg_match($pattern, $version)) { /** * When version is not provided by the extension, * or not standard format or we don't have it * in our reference (ex snmp) because have no sense * be sure at least to return latest PHP version supported. */ $version = ExtensionFactory::getLatestPhpVersion(); } } else { $version = ''; } $ref->loaded = $version; $ref->outdated = version_compare($ref->version, $version, 'gt'); $rows[$key] = $ref; } } ksort($rows); return array_values($rows); }
/** * Initializes the compatibility analyser */ public function __construct() { $pdo = Environment::initRefDb(); $this->metrics = array('versions' => array(), 'extensions' => array(), 'namespaces' => array(), 'objects' => array(), 'interfaces' => array(), 'traits' => array(), 'classes' => array(), 'methods' => array(), 'functions' => array(), 'constants' => array(), 'conditions' => array()); $this->references = new ReferenceCollection(array(), $pdo); }
/** * Gets the application version (long format). * * @return string The application version */ public function getLongVersion() { $v = Environment::versionRefDb(); return sprintf('<info>%s</info> version <comment>%s</comment> DB built <comment>%s</comment>', $this->getName(), $this->getVersion(), $v['build.string']); }
/** * Initializes DB statements * * @return void */ protected function doInitialize() { $pdo = Environment::initRefDb(); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $this->stmtReleases = $pdo->prepare('SELECT rel_date as "date", rel_state as "state",' . ' rel_version as "ext.min", ext_max as "ext.max",' . ' php_min as "php.min", php_max as "php.max"' . ' FROM bartlett_compatinfo_releases r, bartlett_compatinfo_extensions e' . ' WHERE r.ext_name_fk = e.id AND e.name = :name COLLATE NOCASE'); $this->stmtIniEntries = $pdo->prepare('SELECT i.name,' . ' ext_min as "ext.min", ext_max as "ext.max",' . ' php_min as "php.min", php_max as "php.max",' . ' deprecated' . ' FROM bartlett_compatinfo_inientries i, bartlett_compatinfo_extensions e' . ' WHERE i.ext_name_fk = e.id AND e.name = :name COLLATE NOCASE'); $this->stmtClasses = $pdo->prepare('SELECT c.name,' . ' e.name as "ext.name", ext_min as "ext.min", ext_max as "ext.max",' . ' php_min as "php.min", php_max as "php.max"' . ' FROM bartlett_compatinfo_classes c, bartlett_compatinfo_extensions e' . ' WHERE c.ext_name_fk = e.id AND e.name = :name COLLATE NOCASE'); $this->stmtClassMethods = $pdo->prepare('SELECT class_name, m.name, static,' . ' e.name as "ext.name", ext_min as "ext.min", ext_max as "ext.max",' . ' php_min as "php.min", php_max as "php.max"' . ' FROM bartlett_compatinfo_methods m, bartlett_compatinfo_extensions e' . ' WHERE m.ext_name_fk = e.id AND e.name = :name COLLATE NOCASE'); $this->stmtClassConstants = $pdo->prepare('SELECT class_name, c.name,' . ' e.name as "ext.name", ext_min as "ext.min", ext_max as "ext.max",' . ' php_min as "php.min", php_max as "php.max"' . ' FROM bartlett_compatinfo_const c, bartlett_compatinfo_extensions e' . ' WHERE c.ext_name_fk = e.id AND e.name = :name COLLATE NOCASE'); $this->stmtInterfaces = $pdo->prepare('SELECT i.name,' . ' e.name as "ext.name", ext_min as "ext.min", ext_max as "ext.max",' . ' php_min as "php.min", php_max as "php.max"' . ' FROM bartlett_compatinfo_interfaces i, bartlett_compatinfo_extensions e' . ' WHERE i.ext_name_fk = e.id AND e.name = :name COLLATE NOCASE'); $this->stmtFunctions = $pdo->prepare('SELECT f.name,' . ' e.name as "ext.name", ext_min as "ext.min", ext_max as "ext.max",' . ' php_min as "php.min", php_max as "php.max",' . ' parameters, php_excludes as "php.excludes",' . ' deprecated' . ' FROM bartlett_compatinfo_functions f, bartlett_compatinfo_extensions e' . ' WHERE f.ext_name_fk = e.id AND e.name = :name COLLATE NOCASE'); $this->stmtConstants = $pdo->prepare('SELECT c.name,' . ' e.name as "ext.name", ext_min as "ext.min", ext_max as "ext.max",' . ' php_min as "php.min", php_max as "php.max",' . ' php_excludes as "php.excludes"' . ' FROM bartlett_compatinfo_constants c, bartlett_compatinfo_extensions e' . ' WHERE c.ext_name_fk = e.id AND e.name = :name COLLATE NOCASE'); }