diff --git a/src/Composer/Autoload/AutoloadGenerator.php b/src/Composer/Autoload/AutoloadGenerator.php index efb8c7cefa2f..73ec3d5e7f32 100644 --- a/src/Composer/Autoload/AutoloadGenerator.php +++ b/src/Composer/Autoload/AutoloadGenerator.php @@ -208,7 +208,6 @@ public function dump(Config $config, InstalledRepositoryInterface $localRepo, Ro $filesystem->ensureDirectoryExists($targetDir); $vendorPathCode = $filesystem->findShortestPathCode(realpath($targetDir), $vendorPath, true); - $vendorPathCode52 = str_replace('__DIR__', 'dirname(__FILE__)', $vendorPathCode); $vendorPathToTargetDirCode = $filesystem->findShortestPathCode($vendorPath, realpath($targetDir), true); $appBaseDirCode = $filesystem->findShortestPathCode($vendorPath, $basePath, true); @@ -219,7 +218,7 @@ public function dump(Config $config, InstalledRepositoryInterface $localRepo, Ro // autoload_namespaces.php @generated by Composer -\$vendorDir = $vendorPathCode52; +\$vendorDir = $vendorPathCode; \$baseDir = $appBaseDirCode; return array( @@ -231,7 +230,7 @@ public function dump(Config $config, InstalledRepositoryInterface $localRepo, Ro // autoload_psr4.php @generated by Composer -\$vendorDir = $vendorPathCode52; +\$vendorDir = $vendorPathCode; \$baseDir = $appBaseDirCode; return array( @@ -279,7 +278,7 @@ public function dump(Config $config, InstalledRepositoryInterface $localRepo, Ro // autoload_classmap.php @generated by Composer -\$vendorDir = $vendorPathCode52; +\$vendorDir = $vendorPathCode; \$baseDir = $appBaseDirCode; return array( @@ -390,18 +389,18 @@ public static function autoload(\$class) $filesystem->filePutContentsIfModified($targetDir.'/autoload_psr4.php', $psr4File); $filesystem->filePutContentsIfModified($targetDir.'/autoload_classmap.php', $classmapFile); $includePathFilePath = $targetDir.'/include_paths.php'; - if ($includePathFileContents = $this->getIncludePathsFile($packageMap, $filesystem, $basePath, $vendorPath, $vendorPathCode52, $appBaseDirCode)) { + if ($includePathFileContents = $this->getIncludePathsFile($packageMap, $filesystem, $basePath, $vendorPath, $vendorPathCode, $appBaseDirCode)) { $filesystem->filePutContentsIfModified($includePathFilePath, $includePathFileContents); } elseif (file_exists($includePathFilePath)) { unlink($includePathFilePath); } $includeFilesFilePath = $targetDir.'/autoload_files.php'; - if ($includeFilesFileContents = $this->getIncludeFilesFile($autoloads['files'], $filesystem, $basePath, $vendorPath, $vendorPathCode52, $appBaseDirCode)) { + if ($includeFilesFileContents = $this->getIncludeFilesFile($autoloads['files'], $filesystem, $basePath, $vendorPath, $vendorPathCode, $appBaseDirCode)) { $filesystem->filePutContentsIfModified($includeFilesFilePath, $includeFilesFileContents); } elseif (file_exists($includeFilesFilePath)) { unlink($includeFilesFilePath); } - $filesystem->filePutContentsIfModified($targetDir.'/autoload_static.php', $this->getStaticFile($suffix, $targetDir, $vendorPath, $basePath, $staticPhpVersion)); + $filesystem->filePutContentsIfModified($targetDir.'/autoload_static.php', $this->getStaticFile($suffix, $targetDir, $vendorPath, $basePath)); $checkPlatform = $config->get('platform-check') && !($this->platformRequirementFilter instanceof IgnoreAllPlatformRequirementFilter); $platformCheckContent = null; if ($checkPlatform) { @@ -416,7 +415,7 @@ public static function autoload(\$class) unlink($targetDir.'/platform_check.php'); } $filesystem->filePutContentsIfModified($vendorPath.'/autoload.php', $this->getAutoloadFile($vendorPathToTargetDirCode, $suffix)); - $filesystem->filePutContentsIfModified($targetDir.'/autoload_real.php', $this->getAutoloadRealFile(true, (bool) $includePathFileContents, $targetDirLoader, (bool) $includeFilesFileContents, $vendorPathCode, $appBaseDirCode, $suffix, $useGlobalIncludePath, $prependAutoloader, $staticPhpVersion, $checkPlatform)); + $filesystem->filePutContentsIfModified($targetDir.'/autoload_real.php', $this->getAutoloadRealFile(true, (bool) $includePathFileContents, $targetDirLoader, (bool) $includeFilesFileContents, $vendorPathCode, $appBaseDirCode, $suffix, $useGlobalIncludePath, $prependAutoloader, $checkPlatform)); $filesystem->safeCopy(__DIR__.'/ClassLoader.php', $targetDir.'/ClassLoader.php'); $filesystem->safeCopy(__DIR__.'/../../../LICENSE', $targetDir.'/LICENSE'); @@ -938,11 +937,10 @@ protected function getAutoloadFile($vendorPathToTargetDirCode, $suffix) * @param string $suffix * @param bool $useGlobalIncludePath * @param string $prependAutoloader 'true'|'false' - * @param string $staticPhpVersion * @param bool $checkPlatform * @return string */ - protected function getAutoloadRealFile($useClassMap, $useIncludePath, $targetDirLoader, $useIncludeFiles, $vendorPathCode, $appBaseDirCode, $suffix, $useGlobalIncludePath, $prependAutoloader, $staticPhpVersion, $checkPlatform) + protected function getAutoloadRealFile($useClassMap, $useIncludePath, $targetDirLoader, $useIncludeFiles, $vendorPathCode, $appBaseDirCode, $suffix, $useGlobalIncludePath, $prependAutoloader, $checkPlatform) { $file = <<
= $staticPhpVersion && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); - if (\$useStaticLoader) { - require __DIR__ . '/autoload_static.php'; + require __DIR__ . '/autoload_static.php'; + \Composer\Autoload\ComposerStaticInit$suffix::getInitializer(\$loader)(); - call_user_func(\Composer\Autoload\ComposerStaticInit$suffix::getInitializer(\$loader)); - } else { STATIC_INIT; - if (!$this->classMapAuthoritative) { - $file .= <<<'PSR04' - $map = require __DIR__ . '/autoload_namespaces.php'; - foreach ($map as $namespace => $path) { - $loader->set($namespace, $path); - } - - $map = require __DIR__ . '/autoload_psr4.php'; - foreach ($map as $namespace => $path) { - $loader->setPsr4($namespace, $path); - } - - -PSR04; - } - - if ($useClassMap) { - $file .= <<<'CLASSMAP' - $classMap = require __DIR__ . '/autoload_classmap.php'; - if ($classMap) { - $loader->addClassMap($classMap); - } - -CLASSMAP; - } - - $file .= " }\n\n"; - if ($this->classMapAuthoritative) { $file .= <<<'CLASSMAPAUTHORITATIVE' $loader->setClassMapAuthoritative(true); @@ -1074,11 +1041,7 @@ public static function getLoader() if ($useIncludeFiles) { $file .= << \$file) { composerRequire$suffix(\$fileIdentifier, \$file); } @@ -1127,13 +1090,10 @@ function composerRequire$suffix(\$fileIdentifier, \$file) * @param string $targetDir * @param string $vendorPath input for findShortestPathCode * @param string $basePath input for findShortestPathCode - * @param string $staticPhpVersion * @return string */ - protected function getStaticFile($suffix, $targetDir, $vendorPath, $basePath, &$staticPhpVersion) + protected function getStaticFile($suffix, $targetDir, $vendorPath, $basePath) { - $staticPhpVersion = 50600; - $file = <<
$value) { - if (count($value) > 32767) { - // Static arrays are limited to 32767 values on PHP 5.6 - // See https://bugs.php.net/68057 - $staticPhpVersion = 70000; - } $value = strtr( var_export($value, true), array( diff --git a/src/Composer/Json/JsonFile.php b/src/Composer/Json/JsonFile.php index 7b4cf2133cd3..9171048e9c64 100644 --- a/src/Composer/Json/JsonFile.php +++ b/src/Composer/Json/JsonFile.php @@ -31,9 +31,12 @@ class JsonFile const LAX_SCHEMA = 1; const STRICT_SCHEMA = 2; - const JSON_UNESCAPED_SLASHES = 64; - const JSON_PRETTY_PRINT = 128; - const JSON_UNESCAPED_UNICODE = 256; + /** @deprecated Use \JSON_UNESCAPED_SLASHES */ + public const JSON_UNESCAPED_SLASHES = 64; + /** @deprecated Use \JSON_PRETTY_PRINT */ + public const JSON_PRETTY_PRINT = 128; + /** @deprecated Use \JSON_UNESCAPED_UNICODE */ + public const JSON_UNESCAPED_UNICODE = 256; const COMPOSER_SCHEMA_PATH = '/../../../res/composer-schema.json'; @@ -116,12 +119,12 @@ public function read() /** * Writes json file. * - * @param mixed[] $hash writes hash into json file - * @param int $options json_encode options (defaults to JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE) + * @param mixed[] $hash writes hash into json file + * @param int $options json_encode options * @throws \UnexpectedValueException|\Exception * @return void */ - public function write(array $hash, $options = 448) + public function write(array $hash, $options = JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE) { if ($this->path === 'php://memory') { file_put_contents($this->path, static::encode($hash, $options)); @@ -146,7 +149,7 @@ public function write(array $hash, $options = 448) $retries = 3; while ($retries--) { try { - $this->filePutContentsIfModified($this->path, static::encode($hash, $options). ($options & self::JSON_PRETTY_PRINT ? "\n" : '')); + $this->filePutContentsIfModified($this->path, static::encode($hash, $options). ($options & JSON_PRETTY_PRINT ? "\n" : '')); break; } catch (\Exception $e) { if ($retries) { diff --git a/src/Composer/Json/JsonFormatter.php b/src/Composer/Json/JsonFormatter.php index 45f5d3c5f3a3..a85357f875ab 100644 --- a/src/Composer/Json/JsonFormatter.php +++ b/src/Composer/Json/JsonFormatter.php @@ -22,7 +22,7 @@ * @author Konstantin Kudryashiv * @author Jordi Boggiano * - * @abandoned Use json_encode or JsonFile::encode() with modern JSON_* flags to configure formatting - this class will be removed in 3.0 + * @deprecated Use json_encode or JsonFile::encode() with modern JSON_* flags to configure formatting - this class will be removed in 3.0 */ class JsonFormatter { diff --git a/src/Composer/Package/Locker.php b/src/Composer/Package/Locker.php index d8ab66dc4c4a..a5c26215859e 100644 --- a/src/Composer/Package/Locker.php +++ b/src/Composer/Package/Locker.php @@ -403,7 +403,7 @@ public function setLockData(array $packages, $devPackages, array $platformReqs, $this->virtualFileWritten = false; } else { $this->virtualFileWritten = true; - $this->lockDataCache = JsonFile::parseJson(JsonFile::encode($lock, 448 & JsonFile::JSON_PRETTY_PRINT)); + $this->lockDataCache = JsonFile::parseJson(JsonFile::encode($lock)); } return true; diff --git a/src/Composer/Repository/ComposerRepository.php b/src/Composer/Repository/ComposerRepository.php index 5dba6ca22fe9..ede56e3ed906 100644 --- a/src/Composer/Repository/ComposerRepository.php +++ b/src/Composer/Repository/ComposerRepository.php @@ -1514,7 +1514,7 @@ private function asyncFetchFile($filename, $cacheKey, $lastModifiedTime = null) $response->collect(); if ($lastModifiedDate) { $data['last-modified'] = $lastModifiedDate; - $json = JsonFile::encode($data, JsonFile::JSON_UNESCAPED_SLASHES | JsonFile::JSON_UNESCAPED_UNICODE); + $json = JsonFile::encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); } if (!$cache->isReadOnly()) { $cache->write($cacheKey, $json); diff --git a/src/Composer/Util/HttpDownloader.php b/src/Composer/Util/HttpDownloader.php index d1c03b957044..d1c8c1fbdcb7 100644 --- a/src/Composer/Util/HttpDownloader.php +++ b/src/Composer/Util/HttpDownloader.php @@ -110,24 +110,6 @@ public function get($url, $options = array()) $response = $this->getResponse($job['id']); - // check for failed curl response (empty body but successful looking response) - if ( - $this->curl - && PHP_VERSION_ID < 70000 - && $response->getBody() === null - && $response->getStatusCode() === 200 - && $response->getHeader('content-length') !== '0' - ) { - $this->io->writeError('cURL downloader failed to return a response, disabling it and proceeding in slow mode.'); - - $this->curl = null; - - list($job) = $this->addJob(array('url' => $url, 'options' => $options, 'copyTo' => null), true); - $this->wait($job['id']); - - $response = $this->getResponse($job['id']); - } - return $response; } diff --git a/src/Composer/Util/RemoteFilesystem.php b/src/Composer/Util/RemoteFilesystem.php index 1ec560f32281..7455ec7a983d 100644 --- a/src/Composer/Util/RemoteFilesystem.php +++ b/src/Composer/Util/RemoteFilesystem.php @@ -51,8 +51,6 @@ class RemoteFilesystem private $lastProgress; /** @var mixed[] */ private $options = array(); - /** @var array */ - private $peerCertificateMap = array(); /** @var bool */ private $disableTls = false; /** @var string[] */ @@ -463,41 +461,6 @@ protected function get($originUrl, $fileUrl, $additionalOptions = array(), $file } } - // Handle SSL cert match issues - if (false === $result && false !== strpos($errorMessage, 'Peer certificate') && PHP_VERSION_ID < 50600) { - // Certificate name error, PHP doesn't support subjectAltName on PHP < 5.6 - // The procedure to handle sAN for older PHP's is: - // - // 1. Open socket to remote server and fetch certificate (disabling peer - // validation because PHP errors without giving up the certificate.) - // - // 2. Verifying the domain in the URL against the names in the sAN field. - // If there is a match record the authority [host/port], certificate - // common name, and certificate fingerprint. - // - // 3. Retry the original request but changing the CN_match parameter to - // the common name extracted from the certificate in step 2. - // - // 4. To prevent any attempt at being hoodwinked by switching the - // certificate between steps 2 and 3 the fingerprint of the certificate - // presented in step 3 is compared against the one recorded in step 2. - if (CaBundle::isOpensslParseSafe()) { - $certDetails = $this->getCertificateCnAndFp($this->fileUrl, $options); - - if ($certDetails) { - $this->peerCertificateMap[$this->getUrlAuthority($this->fileUrl)] = $certDetails; - - $this->retry = true; - } - } else { - $this->io->writeError(''); - $this->io->writeError(sprintf( - 'Your version of PHP, %s, is affected by CVE-2013-6420 and cannot safely perform certificate validation, we strongly suggest you upgrade.', - PHP_VERSION - )); - } - } - if ($this->retry) { $this->retry = false; @@ -651,35 +614,6 @@ protected function promptAuthAndRetry($httpStatus, $reason = null, $headers = ar protected function getOptionsForUrl($originUrl, $additionalOptions) { $tlsOptions = array(); - - // Setup remaining TLS options - the matching may need monitoring, esp. www vs none in CN - if ($this->disableTls === false && PHP_VERSION_ID < 50600 && !stream_is_local($this->fileUrl)) { - $host = parse_url($this->fileUrl, PHP_URL_HOST); - - $tlsOptions['ssl']['CN_match'] = $host; - $tlsOptions['ssl']['SNI_server_name'] = $host; - - $urlAuthority = $this->getUrlAuthority($this->fileUrl); - - if (isset($this->peerCertificateMap[$urlAuthority])) { - // Handle subjectAltName on lesser PHP's. - $certMap = $this->peerCertificateMap[$urlAuthority]; - - $this->io->writeError('', true, IOInterface::DEBUG); - $this->io->writeError(sprintf( - 'Using %s as CN for subjectAltName enabled host %s', - $certMap['cn'], - $urlAuthority - ), true, IOInterface::DEBUG); - - $tlsOptions['ssl']['CN_match'] = $certMap['cn']; - $tlsOptions['ssl']['peer_fingerprint'] = $certMap['fp']; - } elseif (!CaBundle::isOpensslParseSafe() && $host === 'repo.packagist.org') { - // handle subjectAltName for packagist.org's repo domain on very old PHPs - $tlsOptions['ssl']['CN_match'] = 'packagist.org'; - } - } - $headers = array(); if (extension_loaded('zlib')) { @@ -759,88 +693,6 @@ private function handleRedirect(array $http_response_header, array $additionalOp return false; } - /** - * Fetch certificate common name and fingerprint for validation of SAN. - * - * @todo Remove when PHP 5.6 is minimum supported version. - * - * @param string $url - * @param mixed[] $options - * - * @return ?array{cn: string, fp: string} - */ - private function getCertificateCnAndFp($url, $options) - { - if (PHP_VERSION_ID >= 50600) { - throw new \BadMethodCallException(sprintf( - '%s must not be used on PHP >= 5.6', - __METHOD__ - )); - } - - $context = StreamContextFactory::getContext($url, $options, array('options' => array( - 'ssl' => array( - 'capture_peer_cert' => true, - 'verify_peer' => false, // Yes this is fucking insane! But PHP is lame. - ), ), - )); - - // Ideally this would just use stream_socket_client() to avoid sending a - // HTTP request but that does not capture the certificate. - if (false === $handle = @fopen($url, 'rb', false, $context)) { - return null; - } - - // Close non authenticated connection without reading any content. - fclose($handle); - $handle = null; - - $params = stream_context_get_params($context); - - if (!empty($params['options']['ssl']['peer_certificate'])) { - $peerCertificate = $params['options']['ssl']['peer_certificate']; - - if (TlsHelper::checkCertificateHost($peerCertificate, parse_url($url, PHP_URL_HOST), $commonName)) { - return array( - 'cn' => $commonName, - 'fp' => TlsHelper::getCertificateFingerprint($peerCertificate), - ); - } - } - - return null; - } - - /** - * @param string $url - * - * @return string - */ - private function getUrlAuthority($url) - { - $defaultPorts = array( - 'ftp' => 21, - 'http' => 80, - 'https' => 443, - 'ssh2.sftp' => 22, - 'ssh2.scp' => 22, - ); - - $scheme = parse_url($url, PHP_URL_SCHEME); - - if (!isset($defaultPorts[$scheme])) { - throw new \InvalidArgumentException(sprintf( - 'Could not get default port for unknown scheme: %s', - $scheme - )); - } - - $defaultPort = $defaultPorts[$scheme]; - $port = parse_url($url, PHP_URL_PORT) ?: $defaultPort; - - return parse_url($url, PHP_URL_HOST).':'.$port; - } - /** * @param string|false $result * @param string[] $http_response_header diff --git a/src/Composer/Util/TlsHelper.php b/src/Composer/Util/TlsHelper.php index 16ecbc527ef8..3fe329d4a88a 100644 --- a/src/Composer/Util/TlsHelper.php +++ b/src/Composer/Util/TlsHelper.php @@ -17,6 +17,7 @@ /** * @author Chris Smith + * @deprecated Use composer/ca-bundle and composer/composer 2.2 if you still need PHP 5 compatibility, this class will be removed in Composer 3.0 */ final class TlsHelper { diff --git a/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php b/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php index 623544c7215b..96f8d4584b29 100644 --- a/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php +++ b/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php @@ -641,7 +641,7 @@ public function testPSRToClassMapIgnoresNonPSRClasses() // autoload_classmap.php @generated by Composer -\$vendorDir = dirname(dirname(__FILE__)); +\$vendorDir = dirname(__DIR__); \$baseDir = dirname(\$vendorDir); return array( @@ -1113,7 +1113,7 @@ public function testOverrideVendorsAutoloading() // autoload_namespaces.php @generated by Composer -\$vendorDir = dirname(dirname(__FILE__)); +\$vendorDir = dirname(__DIR__); \$baseDir = dirname(\$vendorDir); return array( @@ -1130,7 +1130,7 @@ public function testOverrideVendorsAutoloading() // autoload_psr4.php @generated by Composer -\$vendorDir = dirname(dirname(__FILE__)); +\$vendorDir = dirname(__DIR__); \$baseDir = dirname(\$vendorDir); return array( @@ -1143,7 +1143,7 @@ public function testOverrideVendorsAutoloading() // autoload_classmap.php @generated by Composer -\$vendorDir = dirname(dirname(__FILE__)); +\$vendorDir = dirname(__DIR__); \$baseDir = dirname(\$vendorDir); return array( @@ -1382,7 +1382,7 @@ public function testVendorDirExcludedFromWorkingDir() // autoload_namespaces.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir).'/working-dir'; return array( @@ -1397,7 +1397,7 @@ public function testVendorDirExcludedFromWorkingDir() // autoload_psr4.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir).'/working-dir'; return array( @@ -1412,7 +1412,7 @@ public function testVendorDirExcludedFromWorkingDir() // autoload_classmap.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir).'/working-dir'; return array( @@ -1471,7 +1471,7 @@ public function testUpLevelRelativePaths() // autoload_namespaces.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir).'/working-dir'; return array( @@ -1485,7 +1485,7 @@ public function testUpLevelRelativePaths() // autoload_psr4.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir).'/working-dir'; return array( @@ -1499,7 +1499,7 @@ public function testUpLevelRelativePaths() // autoload_classmap.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir).'/working-dir'; return array( @@ -1540,7 +1540,7 @@ public function testEmptyPaths() // autoload_namespaces.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); return array( @@ -1554,7 +1554,7 @@ public function testEmptyPaths() // autoload_psr4.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); return array( @@ -1568,7 +1568,7 @@ public function testEmptyPaths() // autoload_classmap.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); return array( @@ -1603,7 +1603,7 @@ public function testVendorSubstringPath() // autoload_namespaces.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); return array( @@ -1617,7 +1617,7 @@ public function testVendorSubstringPath() // autoload_psr4.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); return array( diff --git a/tests/Composer/Test/Autoload/ClassMapGeneratorTest.php b/tests/Composer/Test/Autoload/ClassMapGeneratorTest.php index 2a9485af1845..6316ceb26e84 100644 --- a/tests/Composer/Test/Autoload/ClassMapGeneratorTest.php +++ b/tests/Composer/Test/Autoload/ClassMapGeneratorTest.php @@ -87,21 +87,18 @@ public function getTestCreateMapTests() array(__DIR__ . '/Fixtures/template', array()), ); - if (PHP_VERSION_ID >= 50400) { - $data[] = array(__DIR__ . '/Fixtures/php5.4', array( - 'TFoo' => __DIR__ . '/Fixtures/php5.4/traits.php', - 'CFoo' => __DIR__ . '/Fixtures/php5.4/traits.php', - 'Foo\\TBar' => __DIR__ . '/Fixtures/php5.4/traits.php', - 'Foo\\IBar' => __DIR__ . '/Fixtures/php5.4/traits.php', - 'Foo\\TFooBar' => __DIR__ . '/Fixtures/php5.4/traits.php', - 'Foo\\CBar' => __DIR__ . '/Fixtures/php5.4/traits.php', - )); - } - if (PHP_VERSION_ID >= 70000) { - $data[] = array(__DIR__ . '/Fixtures/php7.0', array( - 'Dummy\Test\AnonClassHolder' => __DIR__ . '/Fixtures/php7.0/anonclass.php', - )); - } + $data[] = array(__DIR__ . '/Fixtures/php5.4', array( + 'TFoo' => __DIR__ . '/Fixtures/php5.4/traits.php', + 'CFoo' => __DIR__ . '/Fixtures/php5.4/traits.php', + 'Foo\\TBar' => __DIR__ . '/Fixtures/php5.4/traits.php', + 'Foo\\IBar' => __DIR__ . '/Fixtures/php5.4/traits.php', + 'Foo\\TFooBar' => __DIR__ . '/Fixtures/php5.4/traits.php', + 'Foo\\CBar' => __DIR__ . '/Fixtures/php5.4/traits.php', + )); + + $data[] = array(__DIR__ . '/Fixtures/php7.0', array( + 'Dummy\Test\AnonClassHolder' => __DIR__ . '/Fixtures/php7.0/anonclass.php', + )); if (PHP_VERSION_ID >= 80100) { $data[] = array(__DIR__ . '/Fixtures/php8.1', array( diff --git a/tests/Composer/Test/Autoload/Fixtures/autoload_classmap.php b/tests/Composer/Test/Autoload/Fixtures/autoload_classmap.php index e49f8b7d8182..e6e196fbde81 100644 --- a/tests/Composer/Test/Autoload/Fixtures/autoload_classmap.php +++ b/tests/Composer/Test/Autoload/Fixtures/autoload_classmap.php @@ -2,7 +2,7 @@ // autoload_classmap.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); return array( diff --git a/tests/Composer/Test/Autoload/Fixtures/autoload_classmap2.php b/tests/Composer/Test/Autoload/Fixtures/autoload_classmap2.php index 60cec93b3fda..be90909f2bbe 100644 --- a/tests/Composer/Test/Autoload/Fixtures/autoload_classmap2.php +++ b/tests/Composer/Test/Autoload/Fixtures/autoload_classmap2.php @@ -2,7 +2,7 @@ // autoload_classmap.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = dirname(dirname($vendorDir)); return array( diff --git a/tests/Composer/Test/Autoload/Fixtures/autoload_classmap3.php b/tests/Composer/Test/Autoload/Fixtures/autoload_classmap3.php index 3bfb2bb8066b..bac85610709b 100644 --- a/tests/Composer/Test/Autoload/Fixtures/autoload_classmap3.php +++ b/tests/Composer/Test/Autoload/Fixtures/autoload_classmap3.php @@ -2,7 +2,7 @@ // autoload_classmap.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = $vendorDir; return array( diff --git a/tests/Composer/Test/Autoload/Fixtures/autoload_classmap4.php b/tests/Composer/Test/Autoload/Fixtures/autoload_classmap4.php index 767ec5e5d1c4..c502deeb69f8 100644 --- a/tests/Composer/Test/Autoload/Fixtures/autoload_classmap4.php +++ b/tests/Composer/Test/Autoload/Fixtures/autoload_classmap4.php @@ -2,7 +2,7 @@ // autoload_classmap.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); return array( diff --git a/tests/Composer/Test/Autoload/Fixtures/autoload_classmap5.php b/tests/Composer/Test/Autoload/Fixtures/autoload_classmap5.php index e88a14606326..30f400927cb1 100644 --- a/tests/Composer/Test/Autoload/Fixtures/autoload_classmap5.php +++ b/tests/Composer/Test/Autoload/Fixtures/autoload_classmap5.php @@ -2,7 +2,7 @@ // autoload_classmap.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); return array( diff --git a/tests/Composer/Test/Autoload/Fixtures/autoload_classmap6.php b/tests/Composer/Test/Autoload/Fixtures/autoload_classmap6.php index d7a357acea91..32dbede6ebb3 100644 --- a/tests/Composer/Test/Autoload/Fixtures/autoload_classmap6.php +++ b/tests/Composer/Test/Autoload/Fixtures/autoload_classmap6.php @@ -2,7 +2,7 @@ // autoload_classmap.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); return array( diff --git a/tests/Composer/Test/Autoload/Fixtures/autoload_classmap7.php b/tests/Composer/Test/Autoload/Fixtures/autoload_classmap7.php index 6818e6b82d8f..d64af0b3c01e 100644 --- a/tests/Composer/Test/Autoload/Fixtures/autoload_classmap7.php +++ b/tests/Composer/Test/Autoload/Fixtures/autoload_classmap7.php @@ -2,7 +2,7 @@ // autoload_classmap.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); return array( diff --git a/tests/Composer/Test/Autoload/Fixtures/autoload_classmap8.php b/tests/Composer/Test/Autoload/Fixtures/autoload_classmap8.php index a002faf5a5d0..62223d962e35 100644 --- a/tests/Composer/Test/Autoload/Fixtures/autoload_classmap8.php +++ b/tests/Composer/Test/Autoload/Fixtures/autoload_classmap8.php @@ -2,7 +2,7 @@ // autoload_classmap.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); return array( diff --git a/tests/Composer/Test/Autoload/Fixtures/autoload_classmap9.php b/tests/Composer/Test/Autoload/Fixtures/autoload_classmap9.php index 75bc86230b5e..1b7069d20e39 100644 --- a/tests/Composer/Test/Autoload/Fixtures/autoload_classmap9.php +++ b/tests/Composer/Test/Autoload/Fixtures/autoload_classmap9.php @@ -2,7 +2,7 @@ // autoload_classmap.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); return array( diff --git a/tests/Composer/Test/Autoload/Fixtures/autoload_files.php b/tests/Composer/Test/Autoload/Fixtures/autoload_files.php index 9ffb4b7e216a..9f6bd9d6d53e 100644 --- a/tests/Composer/Test/Autoload/Fixtures/autoload_files.php +++ b/tests/Composer/Test/Autoload/Fixtures/autoload_files.php @@ -2,7 +2,7 @@ // autoload_files.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); return array( diff --git a/tests/Composer/Test/Autoload/Fixtures/autoload_files2.php b/tests/Composer/Test/Autoload/Fixtures/autoload_files2.php index 7442a7eaf202..a4ed4ae845d3 100644 --- a/tests/Composer/Test/Autoload/Fixtures/autoload_files2.php +++ b/tests/Composer/Test/Autoload/Fixtures/autoload_files2.php @@ -2,7 +2,7 @@ // autoload_files.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); return array( diff --git a/tests/Composer/Test/Autoload/Fixtures/autoload_files_files_by_dependency.php b/tests/Composer/Test/Autoload/Fixtures/autoload_files_files_by_dependency.php index 6c8ce0466986..fa4b4f317bf1 100644 --- a/tests/Composer/Test/Autoload/Fixtures/autoload_files_files_by_dependency.php +++ b/tests/Composer/Test/Autoload/Fixtures/autoload_files_files_by_dependency.php @@ -2,7 +2,7 @@ // autoload_files.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); return array( diff --git a/tests/Composer/Test/Autoload/Fixtures/autoload_files_functions.php b/tests/Composer/Test/Autoload/Fixtures/autoload_files_functions.php index 0889edabce4a..9b4ac6b71305 100644 --- a/tests/Composer/Test/Autoload/Fixtures/autoload_files_functions.php +++ b/tests/Composer/Test/Autoload/Fixtures/autoload_files_functions.php @@ -2,7 +2,7 @@ // autoload_files.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); return array( diff --git a/tests/Composer/Test/Autoload/Fixtures/autoload_files_functions_with_removed_extra.php b/tests/Composer/Test/Autoload/Fixtures/autoload_files_functions_with_removed_extra.php index af3fd800a5ce..93ef1eddfe4d 100644 --- a/tests/Composer/Test/Autoload/Fixtures/autoload_files_functions_with_removed_extra.php +++ b/tests/Composer/Test/Autoload/Fixtures/autoload_files_functions_with_removed_extra.php @@ -2,7 +2,7 @@ // autoload_files.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); return array( diff --git a/tests/Composer/Test/Autoload/Fixtures/autoload_files_target_dir.php b/tests/Composer/Test/Autoload/Fixtures/autoload_files_target_dir.php index e2ca3d25ec2b..21995f8f7a2c 100644 --- a/tests/Composer/Test/Autoload/Fixtures/autoload_files_target_dir.php +++ b/tests/Composer/Test/Autoload/Fixtures/autoload_files_target_dir.php @@ -2,7 +2,7 @@ // autoload_files.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); return array( diff --git a/tests/Composer/Test/Autoload/Fixtures/autoload_main.php b/tests/Composer/Test/Autoload/Fixtures/autoload_main.php index 2f5e863af404..3026720f2aa9 100644 --- a/tests/Composer/Test/Autoload/Fixtures/autoload_main.php +++ b/tests/Composer/Test/Autoload/Fixtures/autoload_main.php @@ -2,7 +2,7 @@ // autoload_namespaces.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); return array( diff --git a/tests/Composer/Test/Autoload/Fixtures/autoload_main2.php b/tests/Composer/Test/Autoload/Fixtures/autoload_main2.php index 93a2ec130f16..9f5e0316e1df 100644 --- a/tests/Composer/Test/Autoload/Fixtures/autoload_main2.php +++ b/tests/Composer/Test/Autoload/Fixtures/autoload_main2.php @@ -2,7 +2,7 @@ // autoload_namespaces.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = dirname(dirname($vendorDir)); return array( diff --git a/tests/Composer/Test/Autoload/Fixtures/autoload_main3.php b/tests/Composer/Test/Autoload/Fixtures/autoload_main3.php index c5a2ab17d808..c16de9e6b2a5 100644 --- a/tests/Composer/Test/Autoload/Fixtures/autoload_main3.php +++ b/tests/Composer/Test/Autoload/Fixtures/autoload_main3.php @@ -2,7 +2,7 @@ // autoload_namespaces.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = $vendorDir; return array( diff --git a/tests/Composer/Test/Autoload/Fixtures/autoload_main4.php b/tests/Composer/Test/Autoload/Fixtures/autoload_main4.php index e6032e67eb5f..e14991d41869 100644 --- a/tests/Composer/Test/Autoload/Fixtures/autoload_main4.php +++ b/tests/Composer/Test/Autoload/Fixtures/autoload_main4.php @@ -2,7 +2,7 @@ // autoload_namespaces.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); return array( diff --git a/tests/Composer/Test/Autoload/Fixtures/autoload_main5.php b/tests/Composer/Test/Autoload/Fixtures/autoload_main5.php index 15cb2622bf9f..533a59a96d5e 100644 --- a/tests/Composer/Test/Autoload/Fixtures/autoload_main5.php +++ b/tests/Composer/Test/Autoload/Fixtures/autoload_main5.php @@ -2,7 +2,7 @@ // autoload_namespaces.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); return array( diff --git a/tests/Composer/Test/Autoload/Fixtures/autoload_phar.php b/tests/Composer/Test/Autoload/Fixtures/autoload_phar.php index 7654005f353b..c916938dfe4c 100644 --- a/tests/Composer/Test/Autoload/Fixtures/autoload_phar.php +++ b/tests/Composer/Test/Autoload/Fixtures/autoload_phar.php @@ -2,7 +2,7 @@ // autoload_namespaces.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); return array( diff --git a/tests/Composer/Test/Autoload/Fixtures/autoload_phar_psr4.php b/tests/Composer/Test/Autoload/Fixtures/autoload_phar_psr4.php index f6142a001b66..4adbc13b4dc5 100644 --- a/tests/Composer/Test/Autoload/Fixtures/autoload_phar_psr4.php +++ b/tests/Composer/Test/Autoload/Fixtures/autoload_phar_psr4.php @@ -2,7 +2,7 @@ // autoload_psr4.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); return array( diff --git a/tests/Composer/Test/Autoload/Fixtures/autoload_psr4.php b/tests/Composer/Test/Autoload/Fixtures/autoload_psr4.php index 78b609869290..cc48ab1c6385 100644 --- a/tests/Composer/Test/Autoload/Fixtures/autoload_psr4.php +++ b/tests/Composer/Test/Autoload/Fixtures/autoload_psr4.php @@ -2,7 +2,7 @@ // autoload_psr4.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); return array( diff --git a/tests/Composer/Test/Autoload/Fixtures/autoload_psr4_2.php b/tests/Composer/Test/Autoload/Fixtures/autoload_psr4_2.php index ab9ca2f5457e..92f42eddf8dd 100644 --- a/tests/Composer/Test/Autoload/Fixtures/autoload_psr4_2.php +++ b/tests/Composer/Test/Autoload/Fixtures/autoload_psr4_2.php @@ -2,7 +2,7 @@ // autoload_psr4.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = dirname(dirname($vendorDir)); return array( diff --git a/tests/Composer/Test/Autoload/Fixtures/autoload_psr4_3.php b/tests/Composer/Test/Autoload/Fixtures/autoload_psr4_3.php index a903b17b858a..37134c608b89 100644 --- a/tests/Composer/Test/Autoload/Fixtures/autoload_psr4_3.php +++ b/tests/Composer/Test/Autoload/Fixtures/autoload_psr4_3.php @@ -2,7 +2,7 @@ // autoload_psr4.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = $vendorDir; return array( diff --git a/tests/Composer/Test/Autoload/Fixtures/autoload_real_files_by_dependency.php b/tests/Composer/Test/Autoload/Fixtures/autoload_real_files_by_dependency.php index 83b8246e1532..0a522f7b0ff0 100644 --- a/tests/Composer/Test/Autoload/Fixtures/autoload_real_files_by_dependency.php +++ b/tests/Composer/Test/Autoload/Fixtures/autoload_real_files_by_dependency.php @@ -23,38 +23,15 @@ public static function getLoader() } spl_autoload_register(array('ComposerAutoloaderInitFilesAutoloadOrder', 'loadClassLoader'), true, true); - self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__))); + self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); spl_autoload_unregister(array('ComposerAutoloaderInitFilesAutoloadOrder', 'loadClassLoader')); - $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); - if ($useStaticLoader) { - require __DIR__ . '/autoload_static.php'; - - call_user_func(\Composer\Autoload\ComposerStaticInitFilesAutoloadOrder::getInitializer($loader)); - } else { - $map = require __DIR__ . '/autoload_namespaces.php'; - foreach ($map as $namespace => $path) { - $loader->set($namespace, $path); - } - - $map = require __DIR__ . '/autoload_psr4.php'; - foreach ($map as $namespace => $path) { - $loader->setPsr4($namespace, $path); - } - - $classMap = require __DIR__ . '/autoload_classmap.php'; - if ($classMap) { - $loader->addClassMap($classMap); - } - } + require __DIR__ . '/autoload_static.php'; + \Composer\Autoload\ComposerStaticInitFilesAutoloadOrder::getInitializer($loader)(); $loader->register(true); - if ($useStaticLoader) { - $includeFiles = Composer\Autoload\ComposerStaticInitFilesAutoloadOrder::$files; - } else { - $includeFiles = require __DIR__ . '/autoload_files.php'; - } + $includeFiles = \Composer\Autoload\ComposerStaticInitFilesAutoloadOrder::$files; foreach ($includeFiles as $fileIdentifier => $file) { composerRequireFilesAutoloadOrder($fileIdentifier, $file); } diff --git a/tests/Composer/Test/Autoload/Fixtures/autoload_real_functions.php b/tests/Composer/Test/Autoload/Fixtures/autoload_real_functions.php index 32248df65d6d..6b60558aef45 100644 --- a/tests/Composer/Test/Autoload/Fixtures/autoload_real_functions.php +++ b/tests/Composer/Test/Autoload/Fixtures/autoload_real_functions.php @@ -23,38 +23,15 @@ public static function getLoader() } spl_autoload_register(array('ComposerAutoloaderInitFilesAutoload', 'loadClassLoader'), true, true); - self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__))); + self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); spl_autoload_unregister(array('ComposerAutoloaderInitFilesAutoload', 'loadClassLoader')); - $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); - if ($useStaticLoader) { - require __DIR__ . '/autoload_static.php'; - - call_user_func(\Composer\Autoload\ComposerStaticInitFilesAutoload::getInitializer($loader)); - } else { - $map = require __DIR__ . '/autoload_namespaces.php'; - foreach ($map as $namespace => $path) { - $loader->set($namespace, $path); - } - - $map = require __DIR__ . '/autoload_psr4.php'; - foreach ($map as $namespace => $path) { - $loader->setPsr4($namespace, $path); - } - - $classMap = require __DIR__ . '/autoload_classmap.php'; - if ($classMap) { - $loader->addClassMap($classMap); - } - } + require __DIR__ . '/autoload_static.php'; + \Composer\Autoload\ComposerStaticInitFilesAutoload::getInitializer($loader)(); $loader->register(true); - if ($useStaticLoader) { - $includeFiles = Composer\Autoload\ComposerStaticInitFilesAutoload::$files; - } else { - $includeFiles = require __DIR__ . '/autoload_files.php'; - } + $includeFiles = \Composer\Autoload\ComposerStaticInitFilesAutoload::$files; foreach ($includeFiles as $fileIdentifier => $file) { composerRequireFilesAutoload($fileIdentifier, $file); } diff --git a/tests/Composer/Test/Autoload/Fixtures/autoload_real_functions_with_include_paths.php b/tests/Composer/Test/Autoload/Fixtures/autoload_real_functions_with_include_paths.php index e6d647004a91..12684a3ba9ab 100644 --- a/tests/Composer/Test/Autoload/Fixtures/autoload_real_functions_with_include_paths.php +++ b/tests/Composer/Test/Autoload/Fixtures/autoload_real_functions_with_include_paths.php @@ -23,42 +23,19 @@ public static function getLoader() } spl_autoload_register(array('ComposerAutoloaderInitFilesAutoload', 'loadClassLoader'), true, true); - self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__))); + self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); spl_autoload_unregister(array('ComposerAutoloaderInitFilesAutoload', 'loadClassLoader')); $includePaths = require __DIR__ . '/include_paths.php'; $includePaths[] = get_include_path(); set_include_path(implode(PATH_SEPARATOR, $includePaths)); - $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); - if ($useStaticLoader) { - require __DIR__ . '/autoload_static.php'; - - call_user_func(\Composer\Autoload\ComposerStaticInitFilesAutoload::getInitializer($loader)); - } else { - $map = require __DIR__ . '/autoload_namespaces.php'; - foreach ($map as $namespace => $path) { - $loader->set($namespace, $path); - } - - $map = require __DIR__ . '/autoload_psr4.php'; - foreach ($map as $namespace => $path) { - $loader->setPsr4($namespace, $path); - } - - $classMap = require __DIR__ . '/autoload_classmap.php'; - if ($classMap) { - $loader->addClassMap($classMap); - } - } + require __DIR__ . '/autoload_static.php'; + \Composer\Autoload\ComposerStaticInitFilesAutoload::getInitializer($loader)(); $loader->register(true); - if ($useStaticLoader) { - $includeFiles = Composer\Autoload\ComposerStaticInitFilesAutoload::$files; - } else { - $includeFiles = require __DIR__ . '/autoload_files.php'; - } + $includeFiles = \Composer\Autoload\ComposerStaticInitFilesAutoload::$files; foreach ($includeFiles as $fileIdentifier => $file) { composerRequireFilesAutoload($fileIdentifier, $file); } diff --git a/tests/Composer/Test/Autoload/Fixtures/autoload_real_functions_with_removed_include_paths_and_autolad_files.php b/tests/Composer/Test/Autoload/Fixtures/autoload_real_functions_with_removed_include_paths_and_autolad_files.php index 965542d83f08..b512f21d1c7c 100644 --- a/tests/Composer/Test/Autoload/Fixtures/autoload_real_functions_with_removed_include_paths_and_autolad_files.php +++ b/tests/Composer/Test/Autoload/Fixtures/autoload_real_functions_with_removed_include_paths_and_autolad_files.php @@ -23,30 +23,11 @@ public static function getLoader() } spl_autoload_register(array('ComposerAutoloaderInitFilesAutoload', 'loadClassLoader'), true, true); - self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__))); + self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); spl_autoload_unregister(array('ComposerAutoloaderInitFilesAutoload', 'loadClassLoader')); - $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); - if ($useStaticLoader) { - require __DIR__ . '/autoload_static.php'; - - call_user_func(\Composer\Autoload\ComposerStaticInitFilesAutoload::getInitializer($loader)); - } else { - $map = require __DIR__ . '/autoload_namespaces.php'; - foreach ($map as $namespace => $path) { - $loader->set($namespace, $path); - } - - $map = require __DIR__ . '/autoload_psr4.php'; - foreach ($map as $namespace => $path) { - $loader->setPsr4($namespace, $path); - } - - $classMap = require __DIR__ . '/autoload_classmap.php'; - if ($classMap) { - $loader->addClassMap($classMap); - } - } + require __DIR__ . '/autoload_static.php'; + \Composer\Autoload\ComposerStaticInitFilesAutoload::getInitializer($loader)(); $loader->register(true); diff --git a/tests/Composer/Test/Autoload/Fixtures/autoload_real_include_path.php b/tests/Composer/Test/Autoload/Fixtures/autoload_real_include_path.php index 1bbf29cb273c..1412c4fba112 100644 --- a/tests/Composer/Test/Autoload/Fixtures/autoload_real_include_path.php +++ b/tests/Composer/Test/Autoload/Fixtures/autoload_real_include_path.php @@ -23,30 +23,11 @@ public static function getLoader() } spl_autoload_register(array('ComposerAutoloaderInitIncludePath', 'loadClassLoader'), true, true); - self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__))); + self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); spl_autoload_unregister(array('ComposerAutoloaderInitIncludePath', 'loadClassLoader')); - $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); - if ($useStaticLoader) { - require __DIR__ . '/autoload_static.php'; - - call_user_func(\Composer\Autoload\ComposerStaticInitIncludePath::getInitializer($loader)); - } else { - $map = require __DIR__ . '/autoload_namespaces.php'; - foreach ($map as $namespace => $path) { - $loader->set($namespace, $path); - } - - $map = require __DIR__ . '/autoload_psr4.php'; - foreach ($map as $namespace => $path) { - $loader->setPsr4($namespace, $path); - } - - $classMap = require __DIR__ . '/autoload_classmap.php'; - if ($classMap) { - $loader->addClassMap($classMap); - } - } + require __DIR__ . '/autoload_static.php'; + \Composer\Autoload\ComposerStaticInitIncludePath::getInitializer($loader)(); $loader->setUseIncludePath(true); spl_autoload_register(array('ComposerAutoloaderInitIncludePath', 'autoload'), true, true); diff --git a/tests/Composer/Test/Autoload/Fixtures/autoload_real_target_dir.php b/tests/Composer/Test/Autoload/Fixtures/autoload_real_target_dir.php index c807f003a26e..732175b2a06a 100644 --- a/tests/Composer/Test/Autoload/Fixtures/autoload_real_target_dir.php +++ b/tests/Composer/Test/Autoload/Fixtures/autoload_real_target_dir.php @@ -23,40 +23,17 @@ public static function getLoader() } spl_autoload_register(array('ComposerAutoloaderInitTargetDir', 'loadClassLoader'), true, true); - self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__))); + self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); spl_autoload_unregister(array('ComposerAutoloaderInitTargetDir', 'loadClassLoader')); - $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); - if ($useStaticLoader) { - require __DIR__ . '/autoload_static.php'; - - call_user_func(\Composer\Autoload\ComposerStaticInitTargetDir::getInitializer($loader)); - } else { - $map = require __DIR__ . '/autoload_namespaces.php'; - foreach ($map as $namespace => $path) { - $loader->set($namespace, $path); - } - - $map = require __DIR__ . '/autoload_psr4.php'; - foreach ($map as $namespace => $path) { - $loader->setPsr4($namespace, $path); - } - - $classMap = require __DIR__ . '/autoload_classmap.php'; - if ($classMap) { - $loader->addClassMap($classMap); - } - } + require __DIR__ . '/autoload_static.php'; + \Composer\Autoload\ComposerStaticInitTargetDir::getInitializer($loader)(); spl_autoload_register(array('ComposerAutoloaderInitTargetDir', 'autoload'), true, true); $loader->register(true); - if ($useStaticLoader) { - $includeFiles = Composer\Autoload\ComposerStaticInitTargetDir::$files; - } else { - $includeFiles = require __DIR__ . '/autoload_files.php'; - } + $includeFiles = \Composer\Autoload\ComposerStaticInitTargetDir::$files; foreach ($includeFiles as $fileIdentifier => $file) { composerRequireTargetDir($fileIdentifier, $file); } diff --git a/tests/Composer/Test/Autoload/Fixtures/autoload_vendors.php b/tests/Composer/Test/Autoload/Fixtures/autoload_vendors.php index 36106d56cbc3..54c0666ee4f0 100644 --- a/tests/Composer/Test/Autoload/Fixtures/autoload_vendors.php +++ b/tests/Composer/Test/Autoload/Fixtures/autoload_vendors.php @@ -2,7 +2,7 @@ // autoload_namespaces.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); return array( diff --git a/tests/Composer/Test/Autoload/Fixtures/include_paths.php b/tests/Composer/Test/Autoload/Fixtures/include_paths.php index 35f66c9ce36a..14917e42cf19 100644 --- a/tests/Composer/Test/Autoload/Fixtures/include_paths.php +++ b/tests/Composer/Test/Autoload/Fixtures/include_paths.php @@ -2,7 +2,7 @@ // include_paths.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); return array( diff --git a/tests/Composer/Test/Autoload/Fixtures/include_paths_functions.php b/tests/Composer/Test/Autoload/Fixtures/include_paths_functions.php index f1095cf6757f..d41eb2c40959 100644 --- a/tests/Composer/Test/Autoload/Fixtures/include_paths_functions.php +++ b/tests/Composer/Test/Autoload/Fixtures/include_paths_functions.php @@ -2,7 +2,7 @@ // include_paths.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); return array( diff --git a/tests/Composer/Test/Autoload/Fixtures/include_paths_functions_with_removed_extra.php b/tests/Composer/Test/Autoload/Fixtures/include_paths_functions_with_removed_extra.php index 4403b11ec031..3cf11d580a3c 100644 --- a/tests/Composer/Test/Autoload/Fixtures/include_paths_functions_with_removed_extra.php +++ b/tests/Composer/Test/Autoload/Fixtures/include_paths_functions_with_removed_extra.php @@ -2,7 +2,7 @@ // include_paths.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); return array( diff --git a/tests/Composer/Test/Installer/BinaryInstallerTest.php b/tests/Composer/Test/Installer/BinaryInstallerTest.php index da7a8c4779f0..fd0ec0aacb4a 100644 --- a/tests/Composer/Test/Installer/BinaryInstallerTest.php +++ b/tests/Composer/Test/Installer/BinaryInstallerTest.php @@ -91,7 +91,7 @@ public function testInstallAndExecBinaryWithFullCompat($contents) public function executableBinaryProvider() { - $tests = array( + return array( 'simple php file' => array(<<<'EOL' array( base64_decode('IyEvdXNyL2Jpbi9lbnYgcGhwCjw/cGhwCgpQaGFyOjptYXBQaGFyKCd0ZXN0LnBoYXInKTsKCnJlcXVpcmUgJ3BoYXI6Ly90ZXN0LnBoYXIvcnVuLnBocCc7CgpfX0hBTFRfQ09NUElMRVIoKTsgPz4NCj4AAAABAAAAEQAAAAEACQAAAHRlc3QucGhhcgAAAAAHAAAAcnVuLnBocCoAAADb9n9hKgAAAMUDDWGkAQAAAAAAADw/cGhwIGVjaG8gInN1Y2Nlc3MgIi4kX1NFUlZFUlsiYXJndiJdWzFdO1SOC0IE3+UN0yzrHIwyspp9slhmAgAAAEdCTUI=') ), - ); - - if (PHP_VERSION_ID >= 70000) { - $tests += array( - 'shebang with strict types declare' => array(<<<'EOL' + 'shebang with strict types declare' => array(<<<'EOL' #!/usr/bin/env php expects($this->any()) ->method('write') ->will($this->returnCallback(function ($value, $options = 0) use (&$lockData) { - $lockData = json_encode($value, JsonFile::JSON_PRETTY_PRINT); + $lockData = json_encode($value, JSON_PRETTY_PRINT); })); $tempLockData = null; @@ -339,7 +339,7 @@ private function doTestIntegration($file, $message, $condition, $composerConfig, $repositoryManager->setLocalRepository(new InstalledFilesystemRepositoryMock($jsonMock)); // emulate a writable lock file - $lockData = $lock ? json_encode($lock, JsonFile::JSON_PRETTY_PRINT) : null; + $lockData = $lock ? json_encode($lock, JSON_PRETTY_PRINT) : null; $lockJsonMock = $this->getMockBuilder('Composer\Json\JsonFile')->disableOriginalConstructor()->getMock(); $lockJsonMock->expects($this->any()) ->method('read') @@ -354,7 +354,7 @@ private function doTestIntegration($file, $message, $condition, $composerConfig, $lockJsonMock->expects($this->any()) ->method('write') ->will($this->returnCallback(function ($value, $options = 0) use (&$lockData) { - $lockData = json_encode($value, JsonFile::JSON_PRETTY_PRINT); + $lockData = json_encode($value, JSON_PRETTY_PRINT); })); if ($expectLock) { diff --git a/tests/Composer/Test/Json/JsonFileTest.php b/tests/Composer/Test/Json/JsonFileTest.php index 3dde97777581..894db2cfedbc 100644 --- a/tests/Composer/Test/Json/JsonFileTest.php +++ b/tests/Composer/Test/Json/JsonFileTest.php @@ -312,7 +312,7 @@ public function testOnlyUnicode() $data = "\\/ƌ"; - $this->assertJsonFormat('"\\\\\\/ƌ"', $data, JsonFile::JSON_UNESCAPED_UNICODE); + $this->assertJsonFormat('"\\\\\\/ƌ"', $data, JSON_UNESCAPED_UNICODE); } public function testEscapedSlashes() diff --git a/tests/Composer/Test/Json/JsonFormatterTest.php b/tests/Composer/Test/Json/JsonFormatterTest.php index 94f95871bb60..d2bd8e0d6cd5 100644 --- a/tests/Composer/Test/Json/JsonFormatterTest.php +++ b/tests/Composer/Test/Json/JsonFormatterTest.php @@ -29,6 +29,7 @@ public function testUnicodeWithPrependedSlash() $backslash = chr(92); $data = '"' . $backslash . $backslash . $backslash . 'u0119"'; $expected = '"' . $backslash . $backslash . 'ę"'; + /** @phpstan-ignore-next-line */ $this->assertEquals($expected, JsonFormatter::format($data, true, true)); } @@ -43,6 +44,7 @@ public function testUtf16SurrogatePair() } $escaped = '"\ud83d\ude00"'; + /** @phpstan-ignore-next-line */ $this->assertEquals($escaped, JsonFormatter::format($escaped, true, true)); } } diff --git a/tests/Composer/Test/Util/TlsHelperTest.php b/tests/Composer/Test/Util/TlsHelperTest.php index 84c826178e39..3b954995134d 100644 --- a/tests/Composer/Test/Util/TlsHelperTest.php +++ b/tests/Composer/Test/Util/TlsHelperTest.php @@ -29,6 +29,7 @@ public function testCheckCertificateHost($expectedResult, $hostname, $certNames) $certificate['subject']['commonName'] = $expectedCn = array_shift($certNames); $certificate['extensions']['subjectAltName'] = $certNames ? 'DNS:'.implode(',DNS:', $certNames) : ''; + // @phpstan-ignore-next-line $result = TlsHelper::checkCertificateHost($certificate, $hostname, $foundCn); if (true === $expectedResult) { @@ -71,6 +72,7 @@ public function testGetCertificateNames() $certificate['subject']['commonName'] = 'example.net'; $certificate['extensions']['subjectAltName'] = 'DNS: example.com, IP: 127.0.0.1, DNS: getcomposer.org, Junk: blah, DNS: composer.example.org'; + // @phpstan-ignore-next-line $names = TlsHelper::getCertificateNames($certificate); $this->assertSame('example.net', $names['cn']);