array ( 'pretty_version' => 'dev-develop', 'version' => 'dev-develop', 'aliases' => array ( ), 'reference' => '56e4f7e7ff00c70c04c56fb74af24e134a0e0ec9', 'name' => '__root__', ), 'versions' => array ( '__root__' => array ( 'pretty_version' => 'dev-develop', 'version' => 'dev-develop', 'aliases' => array ( ), 'reference' => '56e4f7e7ff00c70c04c56fb74af24e134a0e0ec9', ), 'composer/ca-bundle' => array ( 'pretty_version' => '1.3.1', 'version' => '1.3.1.0', 'aliases' => array ( ), 'reference' => '4c679186f2aca4ab6a0f1b0b9cf9252decb44d0b', ), 'dealerdirect/phpcodesniffer-composer-installer' => array ( 'pretty_version' => 'v0.7.2', 'version' => '0.7.2.0', 'aliases' => array ( ), 'reference' => '1c968e542d8843d7cd71de3c5c9c3ff3ad71a1db', ), 'embed/embed' => array ( 'pretty_version' => 'v4.4.3', 'version' => '4.4.3.0', 'aliases' => array ( ), 'reference' => '2ac32581a8617c3bbe593e3d7799ca9db6974471', ), 'gettext/gettext' => array ( 'pretty_version' => 'v5.6.1', 'version' => '5.6.1.0', 'aliases' => array ( ), 'reference' => '017e249601d32b9a88c2eb4c10eac89bf582a7d3', ), 'gettext/languages' => array ( 'pretty_version' => '2.9.0', 'version' => '2.9.0.0', 'aliases' => array ( ), 'reference' => 'ed56dd2c7f4024cc953ed180d25f02f2640e3ffa', ), 'grandel/include-directory' => array ( 'pretty_version' => 'v0.2.2', 'version' => '0.2.2.0', 'aliases' => array ( ), 'reference' => 'a5c830e8f1527c818b521ab18f2accecb02f9919', ), 'guzzlehttp/guzzle' => array ( 'pretty_version' => '7.4.1', 'version' => '7.4.1.0', 'aliases' => array ( ), 'reference' => 'ee0a041b1760e6a53d2a39c8c34115adc2af2c79', ), 'guzzlehttp/promises' => array ( 'pretty_version' => '1.5.1', 'version' => '1.5.1.0', 'aliases' => array ( ), 'reference' => 'fe752aedc9fd8fcca3fe7ad05d419d32998a06da', ), 'guzzlehttp/psr7' => array ( 'pretty_version' => '2.1.0', 'version' => '2.1.0.0', 'aliases' => array ( ), 'reference' => '089edd38f5b8abba6cb01567c2a8aaa47cec4c72', ), 'http-interop/http-factory-guzzle' => array ( 'pretty_version' => '1.2.0', 'version' => '1.2.0.0', 'aliases' => array ( ), 'reference' => '8f06e92b95405216b237521cc64c804dd44c4a81', ), 'laminas/laminas-diactoros' => array ( 'pretty_version' => '2.8.0', 'version' => '2.8.0.0', 'aliases' => array ( ), 'reference' => '0c26ef1d95b6d7e6e3943a243ba3dc0797227199', ), 'ml/iri' => array ( 'pretty_version' => '1.1.4', 'version' => '1.1.4.0', 'aliases' => array ( ), 'reference' => 'cbd44fa913e00ea624241b38cefaa99da8d71341', ), 'ml/json-ld' => array ( 'pretty_version' => '1.2.0', 'version' => '1.2.0.0', 'aliases' => array ( ), 'reference' => 'c74a1aed5979ed1cfb1be35a55a305fd30e30b93', ), 'oscarotero/html-parser' => array ( 'pretty_version' => 'v0.1.6', 'version' => '0.1.6.0', 'aliases' => array ( ), 'reference' => 'b61e92f634d0dc184339d24630a6968d3ac64ded', ), 'psr/http-client' => array ( 'pretty_version' => '1.0.1', 'version' => '1.0.1.0', 'aliases' => array ( ), 'reference' => '2dfb5f6c5eff0e91e20e913f8c5452ed95b86621', ), 'psr/http-client-implementation' => array ( 'provided' => array ( 0 => '1.0', ), ), 'psr/http-factory' => array ( 'pretty_version' => '1.0.1', 'version' => '1.0.1.0', 'aliases' => array ( ), 'reference' => '12ac7fcd07e5b077433f5f2bee95b3a771bf61be', ), 'psr/http-factory-implementation' => array ( 'provided' => array ( 0 => '1.0', 1 => '^1.0', ), ), 'psr/http-message' => array ( 'pretty_version' => '1.0.1', 'version' => '1.0.1.0', 'aliases' => array ( ), 'reference' => 'f6561bf28d520154e4b0ec72be95418abe6d9363', ), 'psr/http-message-implementation' => array ( 'provided' => array ( 0 => '1.0', ), ), 'qferr/mjml-php' => array ( 'pretty_version' => '1.1.0', 'version' => '1.1.0.0', 'aliases' => array ( ), 'reference' => 'c6ea36c190e304e399a957f7e03b5a378faf41b9', ), 'ralouphie/getallheaders' => array ( 'pretty_version' => '3.0.3', 'version' => '3.0.3.0', 'aliases' => array ( ), 'reference' => '120b605dfeb996808c31b6477290a714d356e822', ), 'squizlabs/php_codesniffer' => array ( 'pretty_version' => '3.6.2', 'version' => '3.6.2.0', 'aliases' => array ( ), 'reference' => '5e4e71592f69da17871dba6e80dd51bce74a351a', ), 'symfony/deprecation-contracts' => array ( 'pretty_version' => 'v3.0.0', 'version' => '3.0.0.0', 'aliases' => array ( ), 'reference' => 'c726b64c1ccfe2896cb7df2e1331c357ad1c8ced', ), 'symfony/polyfill-php80' => array ( 'pretty_version' => 'v1.25.0', 'version' => '1.25.0.0', 'aliases' => array ( ), 'reference' => '4407588e0d3f1f52efb65fbe92babe41f37fe50c', ), 'symfony/process' => array ( 'pretty_version' => 'v5.4.5', 'version' => '5.4.5.0', 'aliases' => array ( ), 'reference' => '95440409896f90a5f85db07a32b517ecec17fa4c', ), ), ); private static $canGetVendors; private static $installedByVendor = array(); public static function getInstalledPackages() { $packages = array(); foreach (self::getInstalled() as $installed) { $packages[] = array_keys($installed['versions']); } if (1 === \count($packages)) { return $packages[0]; } return array_keys(array_flip(\call_user_func_array('array_merge', $packages))); } public static function isInstalled($packageName) { foreach (self::getInstalled() as $installed) { if (isset($installed['versions'][$packageName])) { return true; } } return false; } public static function satisfies(VersionParser $parser, $packageName, $constraint) { $constraint = $parser->parseConstraints($constraint); $provided = $parser->parseConstraints(self::getVersionRanges($packageName)); return $provided->matches($constraint); } public static function getVersionRanges($packageName) { foreach (self::getInstalled() as $installed) { if (!isset($installed['versions'][$packageName])) { continue; } $ranges = array(); if (isset($installed['versions'][$packageName]['pretty_version'])) { $ranges[] = $installed['versions'][$packageName]['pretty_version']; } if (array_key_exists('aliases', $installed['versions'][$packageName])) { $ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']); } if (array_key_exists('replaced', $installed['versions'][$packageName])) { $ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']); } if (array_key_exists('provided', $installed['versions'][$packageName])) { $ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']); } return implode(' || ', $ranges); } throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); } public static function getVersion($packageName) { foreach (self::getInstalled() as $installed) { if (!isset($installed['versions'][$packageName])) { continue; } if (!isset($installed['versions'][$packageName]['version'])) { return null; } return $installed['versions'][$packageName]['version']; } throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); } public static function getPrettyVersion($packageName) { foreach (self::getInstalled() as $installed) { if (!isset($installed['versions'][$packageName])) { continue; } if (!isset($installed['versions'][$packageName]['pretty_version'])) { return null; } return $installed['versions'][$packageName]['pretty_version']; } throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); } public static function getReference($packageName) { foreach (self::getInstalled() as $installed) { if (!isset($installed['versions'][$packageName])) { continue; } if (!isset($installed['versions'][$packageName]['reference'])) { return null; } return $installed['versions'][$packageName]['reference']; } throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); } public static function getRootPackage() { $installed = self::getInstalled(); return $installed[0]['root']; } public static function getRawData() { return self::$installed; } public static function reload($data) { self::$installed = $data; self::$installedByVendor = array(); } private static function getInstalled() { if (null === self::$canGetVendors) { self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders'); } $installed = array(); if (self::$canGetVendors) { foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) { if (isset(self::$installedByVendor[$vendorDir])) { $installed[] = self::$installedByVendor[$vendorDir]; } elseif (is_file($vendorDir.'/composer/installed.php')) { $installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php'; } } } $installed[] = self::$installed; return $installed; } }