1
0
Fork 0

Merge pull request #10428 from Seldaek/deprecations

Deprecations & more php version cleanups
pull/10430/head
Jordi Boggiano 2022-01-04 16:30:55 +01:00 committed by GitHub
commit 404c58a17f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
50 changed files with 117 additions and 460 deletions

View File

@ -208,7 +208,6 @@ class AutoloadGenerator
$filesystem->ensureDirectoryExists($targetDir); $filesystem->ensureDirectoryExists($targetDir);
$vendorPathCode = $filesystem->findShortestPathCode(realpath($targetDir), $vendorPath, true); $vendorPathCode = $filesystem->findShortestPathCode(realpath($targetDir), $vendorPath, true);
$vendorPathCode52 = str_replace('__DIR__', 'dirname(__FILE__)', $vendorPathCode);
$vendorPathToTargetDirCode = $filesystem->findShortestPathCode($vendorPath, realpath($targetDir), true); $vendorPathToTargetDirCode = $filesystem->findShortestPathCode($vendorPath, realpath($targetDir), true);
$appBaseDirCode = $filesystem->findShortestPathCode($vendorPath, $basePath, true); $appBaseDirCode = $filesystem->findShortestPathCode($vendorPath, $basePath, true);
@ -219,7 +218,7 @@ class AutoloadGenerator
// autoload_namespaces.php @generated by Composer // autoload_namespaces.php @generated by Composer
\$vendorDir = $vendorPathCode52; \$vendorDir = $vendorPathCode;
\$baseDir = $appBaseDirCode; \$baseDir = $appBaseDirCode;
return array( return array(
@ -231,7 +230,7 @@ EOF;
// autoload_psr4.php @generated by Composer // autoload_psr4.php @generated by Composer
\$vendorDir = $vendorPathCode52; \$vendorDir = $vendorPathCode;
\$baseDir = $appBaseDirCode; \$baseDir = $appBaseDirCode;
return array( return array(
@ -279,7 +278,7 @@ EOF;
// autoload_classmap.php @generated by Composer // autoload_classmap.php @generated by Composer
\$vendorDir = $vendorPathCode52; \$vendorDir = $vendorPathCode;
\$baseDir = $appBaseDirCode; \$baseDir = $appBaseDirCode;
return array( return array(
@ -390,18 +389,18 @@ EOF;
$filesystem->filePutContentsIfModified($targetDir.'/autoload_psr4.php', $psr4File); $filesystem->filePutContentsIfModified($targetDir.'/autoload_psr4.php', $psr4File);
$filesystem->filePutContentsIfModified($targetDir.'/autoload_classmap.php', $classmapFile); $filesystem->filePutContentsIfModified($targetDir.'/autoload_classmap.php', $classmapFile);
$includePathFilePath = $targetDir.'/include_paths.php'; $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); $filesystem->filePutContentsIfModified($includePathFilePath, $includePathFileContents);
} elseif (file_exists($includePathFilePath)) { } elseif (file_exists($includePathFilePath)) {
unlink($includePathFilePath); unlink($includePathFilePath);
} }
$includeFilesFilePath = $targetDir.'/autoload_files.php'; $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); $filesystem->filePutContentsIfModified($includeFilesFilePath, $includeFilesFileContents);
} elseif (file_exists($includeFilesFilePath)) { } elseif (file_exists($includeFilesFilePath)) {
unlink($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); $checkPlatform = $config->get('platform-check') && !($this->platformRequirementFilter instanceof IgnoreAllPlatformRequirementFilter);
$platformCheckContent = null; $platformCheckContent = null;
if ($checkPlatform) { if ($checkPlatform) {
@ -416,7 +415,7 @@ EOF;
unlink($targetDir.'/platform_check.php'); unlink($targetDir.'/platform_check.php');
} }
$filesystem->filePutContentsIfModified($vendorPath.'/autoload.php', $this->getAutoloadFile($vendorPathToTargetDirCode, $suffix)); $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__.'/ClassLoader.php', $targetDir.'/ClassLoader.php');
$filesystem->safeCopy(__DIR__.'/../../../LICENSE', $targetDir.'/LICENSE'); $filesystem->safeCopy(__DIR__.'/../../../LICENSE', $targetDir.'/LICENSE');
@ -938,11 +937,10 @@ AUTOLOAD;
* @param string $suffix * @param string $suffix
* @param bool $useGlobalIncludePath * @param bool $useGlobalIncludePath
* @param string $prependAutoloader 'true'|'false' * @param string $prependAutoloader 'true'|'false'
* @param string $staticPhpVersion
* @param bool $checkPlatform * @param bool $checkPlatform
* @return string * @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 = <<<HEADER $file = <<<HEADER
<?php <?php
@ -982,7 +980,7 @@ PLATFORM_CHECK;
$file .= <<<CLASSLOADER_INIT $file .= <<<CLASSLOADER_INIT
spl_autoload_register(array('ComposerAutoloaderInit$suffix', 'loadClassLoader'), true, $prependAutoloader); spl_autoload_register(array('ComposerAutoloaderInit$suffix', 'loadClassLoader'), true, $prependAutoloader);
self::\$loader = \$loader = new \\Composer\\Autoload\\ClassLoader(\\dirname(\\dirname(__FILE__))); self::\$loader = \$loader = new \\Composer\\Autoload\\ClassLoader(\\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInit$suffix', 'loadClassLoader')); spl_autoload_unregister(array('ComposerAutoloaderInit$suffix', 'loadClassLoader'));
@ -999,43 +997,12 @@ INCLUDE_PATH;
} }
$file .= <<<STATIC_INIT $file .= <<<STATIC_INIT
\$useStaticLoader = PHP_VERSION_ID >= $staticPhpVersion && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); require __DIR__ . '/autoload_static.php';
if (\$useStaticLoader) { \Composer\Autoload\ComposerStaticInit$suffix::getInitializer(\$loader)();
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit$suffix::getInitializer(\$loader));
} else {
STATIC_INIT; 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) { if ($this->classMapAuthoritative) {
$file .= <<<'CLASSMAPAUTHORITATIVE' $file .= <<<'CLASSMAPAUTHORITATIVE'
$loader->setClassMapAuthoritative(true); $loader->setClassMapAuthoritative(true);
@ -1074,11 +1041,7 @@ REGISTER_LOADER;
if ($useIncludeFiles) { if ($useIncludeFiles) {
$file .= <<<INCLUDE_FILES $file .= <<<INCLUDE_FILES
if (\$useStaticLoader) { \$includeFiles = \Composer\Autoload\ComposerStaticInit$suffix::\$files;
\$includeFiles = Composer\Autoload\ComposerStaticInit$suffix::\$files;
} else {
\$includeFiles = require __DIR__ . '/autoload_files.php';
}
foreach (\$includeFiles as \$fileIdentifier => \$file) { foreach (\$includeFiles as \$fileIdentifier => \$file) {
composerRequire$suffix(\$fileIdentifier, \$file); composerRequire$suffix(\$fileIdentifier, \$file);
} }
@ -1127,13 +1090,10 @@ FOOTER;
* @param string $targetDir * @param string $targetDir
* @param string $vendorPath input for findShortestPathCode * @param string $vendorPath input for findShortestPathCode
* @param string $basePath input for findShortestPathCode * @param string $basePath input for findShortestPathCode
* @param string $staticPhpVersion
* @return string * @return string
*/ */
protected function getStaticFile($suffix, $targetDir, $vendorPath, $basePath, &$staticPhpVersion) protected function getStaticFile($suffix, $targetDir, $vendorPath, $basePath)
{ {
$staticPhpVersion = 50600;
$file = <<<HEADER $file = <<<HEADER
<?php <?php
@ -1191,11 +1151,6 @@ HEADER;
} }
foreach ($maps as $prop => $value) { foreach ($maps as $prop => $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( $value = strtr(
var_export($value, true), var_export($value, true),
array( array(

View File

@ -31,9 +31,12 @@ class JsonFile
const LAX_SCHEMA = 1; const LAX_SCHEMA = 1;
const STRICT_SCHEMA = 2; const STRICT_SCHEMA = 2;
const JSON_UNESCAPED_SLASHES = 64; /** @deprecated Use \JSON_UNESCAPED_SLASHES */
const JSON_PRETTY_PRINT = 128; public const JSON_UNESCAPED_SLASHES = 64;
const JSON_UNESCAPED_UNICODE = 256; /** @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'; const COMPOSER_SCHEMA_PATH = '/../../../res/composer-schema.json';
@ -116,12 +119,12 @@ class JsonFile
/** /**
* Writes json file. * Writes json file.
* *
* @param mixed[] $hash writes hash into 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 int $options json_encode options
* @throws \UnexpectedValueException|\Exception * @throws \UnexpectedValueException|\Exception
* @return void * @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') { if ($this->path === 'php://memory') {
file_put_contents($this->path, static::encode($hash, $options)); file_put_contents($this->path, static::encode($hash, $options));
@ -146,7 +149,7 @@ class JsonFile
$retries = 3; $retries = 3;
while ($retries--) { while ($retries--) {
try { 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; break;
} catch (\Exception $e) { } catch (\Exception $e) {
if ($retries) { if ($retries) {

View File

@ -22,7 +22,7 @@ use Composer\Pcre\Preg;
* @author Konstantin Kudryashiv <ever.zet@gmail.com> * @author Konstantin Kudryashiv <ever.zet@gmail.com>
* @author Jordi Boggiano <j.boggiano@seld.be> * @author Jordi Boggiano <j.boggiano@seld.be>
* *
* @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 class JsonFormatter
{ {

View File

@ -403,7 +403,7 @@ class Locker
$this->virtualFileWritten = false; $this->virtualFileWritten = false;
} else { } else {
$this->virtualFileWritten = true; $this->virtualFileWritten = true;
$this->lockDataCache = JsonFile::parseJson(JsonFile::encode($lock, 448 & JsonFile::JSON_PRETTY_PRINT)); $this->lockDataCache = JsonFile::parseJson(JsonFile::encode($lock));
} }
return true; return true;

View File

@ -1514,7 +1514,7 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
$response->collect(); $response->collect();
if ($lastModifiedDate) { if ($lastModifiedDate) {
$data['last-modified'] = $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()) { if (!$cache->isReadOnly()) {
$cache->write($cacheKey, $json); $cache->write($cacheKey, $json);

View File

@ -110,24 +110,6 @@ class HttpDownloader
$response = $this->getResponse($job['id']); $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('<warning>cURL downloader failed to return a response, disabling it and proceeding in slow mode.</warning>');
$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; return $response;
} }

View File

@ -51,8 +51,6 @@ class RemoteFilesystem
private $lastProgress; private $lastProgress;
/** @var mixed[] */ /** @var mixed[] */
private $options = array(); private $options = array();
/** @var array<string, array{cn: string, fp: string}> */
private $peerCertificateMap = array();
/** @var bool */ /** @var bool */
private $disableTls = false; private $disableTls = false;
/** @var string[] */ /** @var string[] */
@ -463,41 +461,6 @@ class RemoteFilesystem
} }
} }
// 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(
'<error>Your version of PHP, %s, is affected by CVE-2013-6420 and cannot safely perform certificate validation, we strongly suggest you upgrade.</error>',
PHP_VERSION
));
}
}
if ($this->retry) { if ($this->retry) {
$this->retry = false; $this->retry = false;
@ -651,35 +614,6 @@ class RemoteFilesystem
protected function getOptionsForUrl($originUrl, $additionalOptions) protected function getOptionsForUrl($originUrl, $additionalOptions)
{ {
$tlsOptions = array(); $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 <info>%s</info> as CN for subjectAltName enabled host <info>%s</info>',
$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(); $headers = array();
if (extension_loaded('zlib')) { if (extension_loaded('zlib')) {
@ -759,88 +693,6 @@ class RemoteFilesystem
return false; 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|false $result
* @param string[] $http_response_header * @param string[] $http_response_header

View File

@ -17,6 +17,7 @@ use Composer\Pcre\Preg;
/** /**
* @author Chris Smith <chris@cs278.org> * @author Chris Smith <chris@cs278.org>
* @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 final class TlsHelper
{ {

View File

@ -641,7 +641,7 @@ class AutoloadGeneratorTest extends TestCase
// autoload_classmap.php @generated by Composer // autoload_classmap.php @generated by Composer
\$vendorDir = dirname(dirname(__FILE__)); \$vendorDir = dirname(__DIR__);
\$baseDir = dirname(\$vendorDir); \$baseDir = dirname(\$vendorDir);
return array( return array(
@ -1113,7 +1113,7 @@ EOF;
// autoload_namespaces.php @generated by Composer // autoload_namespaces.php @generated by Composer
\$vendorDir = dirname(dirname(__FILE__)); \$vendorDir = dirname(__DIR__);
\$baseDir = dirname(\$vendorDir); \$baseDir = dirname(\$vendorDir);
return array( return array(
@ -1130,7 +1130,7 @@ EOF;
// autoload_psr4.php @generated by Composer // autoload_psr4.php @generated by Composer
\$vendorDir = dirname(dirname(__FILE__)); \$vendorDir = dirname(__DIR__);
\$baseDir = dirname(\$vendorDir); \$baseDir = dirname(\$vendorDir);
return array( return array(
@ -1143,7 +1143,7 @@ EOF;
// autoload_classmap.php @generated by Composer // autoload_classmap.php @generated by Composer
\$vendorDir = dirname(dirname(__FILE__)); \$vendorDir = dirname(__DIR__);
\$baseDir = dirname(\$vendorDir); \$baseDir = dirname(\$vendorDir);
return array( return array(
@ -1382,7 +1382,7 @@ EOF;
// autoload_namespaces.php @generated by Composer // autoload_namespaces.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__)); $vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir).'/working-dir'; $baseDir = dirname($vendorDir).'/working-dir';
return array( return array(
@ -1397,7 +1397,7 @@ EOF;
// autoload_psr4.php @generated by Composer // autoload_psr4.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__)); $vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir).'/working-dir'; $baseDir = dirname($vendorDir).'/working-dir';
return array( return array(
@ -1412,7 +1412,7 @@ EOF;
// autoload_classmap.php @generated by Composer // autoload_classmap.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__)); $vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir).'/working-dir'; $baseDir = dirname($vendorDir).'/working-dir';
return array( return array(
@ -1471,7 +1471,7 @@ EOF;
// autoload_namespaces.php @generated by Composer // autoload_namespaces.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__)); $vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir).'/working-dir'; $baseDir = dirname($vendorDir).'/working-dir';
return array( return array(
@ -1485,7 +1485,7 @@ EOF;
// autoload_psr4.php @generated by Composer // autoload_psr4.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__)); $vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir).'/working-dir'; $baseDir = dirname($vendorDir).'/working-dir';
return array( return array(
@ -1499,7 +1499,7 @@ EOF;
// autoload_classmap.php @generated by Composer // autoload_classmap.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__)); $vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir).'/working-dir'; $baseDir = dirname($vendorDir).'/working-dir';
return array( return array(
@ -1540,7 +1540,7 @@ EOF;
// autoload_namespaces.php @generated by Composer // autoload_namespaces.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__)); $vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir); $baseDir = dirname($vendorDir);
return array( return array(
@ -1554,7 +1554,7 @@ EOF;
// autoload_psr4.php @generated by Composer // autoload_psr4.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__)); $vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir); $baseDir = dirname($vendorDir);
return array( return array(
@ -1568,7 +1568,7 @@ EOF;
// autoload_classmap.php @generated by Composer // autoload_classmap.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__)); $vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir); $baseDir = dirname($vendorDir);
return array( return array(
@ -1603,7 +1603,7 @@ EOF;
// autoload_namespaces.php @generated by Composer // autoload_namespaces.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__)); $vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir); $baseDir = dirname($vendorDir);
return array( return array(
@ -1617,7 +1617,7 @@ EOF;
// autoload_psr4.php @generated by Composer // autoload_psr4.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__)); $vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir); $baseDir = dirname($vendorDir);
return array( return array(

View File

@ -87,21 +87,18 @@ class ClassMapGeneratorTest extends TestCase
array(__DIR__ . '/Fixtures/template', array()), array(__DIR__ . '/Fixtures/template', array()),
); );
if (PHP_VERSION_ID >= 50400) { $data[] = array(__DIR__ . '/Fixtures/php5.4', array(
$data[] = array(__DIR__ . '/Fixtures/php5.4', array( 'TFoo' => __DIR__ . '/Fixtures/php5.4/traits.php',
'TFoo' => __DIR__ . '/Fixtures/php5.4/traits.php', 'CFoo' => __DIR__ . '/Fixtures/php5.4/traits.php',
'CFoo' => __DIR__ . '/Fixtures/php5.4/traits.php', 'Foo\\TBar' => __DIR__ . '/Fixtures/php5.4/traits.php',
'Foo\\TBar' => __DIR__ . '/Fixtures/php5.4/traits.php', 'Foo\\IBar' => __DIR__ . '/Fixtures/php5.4/traits.php',
'Foo\\IBar' => __DIR__ . '/Fixtures/php5.4/traits.php', 'Foo\\TFooBar' => __DIR__ . '/Fixtures/php5.4/traits.php',
'Foo\\TFooBar' => __DIR__ . '/Fixtures/php5.4/traits.php', 'Foo\\CBar' => __DIR__ . '/Fixtures/php5.4/traits.php',
'Foo\\CBar' => __DIR__ . '/Fixtures/php5.4/traits.php', ));
));
} $data[] = array(__DIR__ . '/Fixtures/php7.0', array(
if (PHP_VERSION_ID >= 70000) { 'Dummy\Test\AnonClassHolder' => __DIR__ . '/Fixtures/php7.0/anonclass.php',
$data[] = array(__DIR__ . '/Fixtures/php7.0', array( ));
'Dummy\Test\AnonClassHolder' => __DIR__ . '/Fixtures/php7.0/anonclass.php',
));
}
if (PHP_VERSION_ID >= 80100) { if (PHP_VERSION_ID >= 80100) {
$data[] = array(__DIR__ . '/Fixtures/php8.1', array( $data[] = array(__DIR__ . '/Fixtures/php8.1', array(

View File

@ -2,7 +2,7 @@
// autoload_classmap.php @generated by Composer // autoload_classmap.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__)); $vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir); $baseDir = dirname($vendorDir);
return array( return array(

View File

@ -2,7 +2,7 @@
// autoload_classmap.php @generated by Composer // autoload_classmap.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__)); $vendorDir = dirname(__DIR__);
$baseDir = dirname(dirname($vendorDir)); $baseDir = dirname(dirname($vendorDir));
return array( return array(

View File

@ -2,7 +2,7 @@
// autoload_classmap.php @generated by Composer // autoload_classmap.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__)); $vendorDir = dirname(__DIR__);
$baseDir = $vendorDir; $baseDir = $vendorDir;
return array( return array(

View File

@ -2,7 +2,7 @@
// autoload_classmap.php @generated by Composer // autoload_classmap.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__)); $vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir); $baseDir = dirname($vendorDir);
return array( return array(

View File

@ -2,7 +2,7 @@
// autoload_classmap.php @generated by Composer // autoload_classmap.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__)); $vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir); $baseDir = dirname($vendorDir);
return array( return array(

View File

@ -2,7 +2,7 @@
// autoload_classmap.php @generated by Composer // autoload_classmap.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__)); $vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir); $baseDir = dirname($vendorDir);
return array( return array(

View File

@ -2,7 +2,7 @@
// autoload_classmap.php @generated by Composer // autoload_classmap.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__)); $vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir); $baseDir = dirname($vendorDir);
return array( return array(

View File

@ -2,7 +2,7 @@
// autoload_classmap.php @generated by Composer // autoload_classmap.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__)); $vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir); $baseDir = dirname($vendorDir);
return array( return array(

View File

@ -2,7 +2,7 @@
// autoload_classmap.php @generated by Composer // autoload_classmap.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__)); $vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir); $baseDir = dirname($vendorDir);
return array( return array(

View File

@ -2,7 +2,7 @@
// autoload_files.php @generated by Composer // autoload_files.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__)); $vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir); $baseDir = dirname($vendorDir);
return array( return array(

View File

@ -2,7 +2,7 @@
// autoload_files.php @generated by Composer // autoload_files.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__)); $vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir); $baseDir = dirname($vendorDir);
return array( return array(

View File

@ -2,7 +2,7 @@
// autoload_files.php @generated by Composer // autoload_files.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__)); $vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir); $baseDir = dirname($vendorDir);
return array( return array(

View File

@ -2,7 +2,7 @@
// autoload_files.php @generated by Composer // autoload_files.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__)); $vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir); $baseDir = dirname($vendorDir);
return array( return array(

View File

@ -2,7 +2,7 @@
// autoload_files.php @generated by Composer // autoload_files.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__)); $vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir); $baseDir = dirname($vendorDir);
return array( return array(

View File

@ -2,7 +2,7 @@
// autoload_files.php @generated by Composer // autoload_files.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__)); $vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir); $baseDir = dirname($vendorDir);
return array( return array(

View File

@ -2,7 +2,7 @@
// autoload_namespaces.php @generated by Composer // autoload_namespaces.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__)); $vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir); $baseDir = dirname($vendorDir);
return array( return array(

View File

@ -2,7 +2,7 @@
// autoload_namespaces.php @generated by Composer // autoload_namespaces.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__)); $vendorDir = dirname(__DIR__);
$baseDir = dirname(dirname($vendorDir)); $baseDir = dirname(dirname($vendorDir));
return array( return array(

View File

@ -2,7 +2,7 @@
// autoload_namespaces.php @generated by Composer // autoload_namespaces.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__)); $vendorDir = dirname(__DIR__);
$baseDir = $vendorDir; $baseDir = $vendorDir;
return array( return array(

View File

@ -2,7 +2,7 @@
// autoload_namespaces.php @generated by Composer // autoload_namespaces.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__)); $vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir); $baseDir = dirname($vendorDir);
return array( return array(

View File

@ -2,7 +2,7 @@
// autoload_namespaces.php @generated by Composer // autoload_namespaces.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__)); $vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir); $baseDir = dirname($vendorDir);
return array( return array(

View File

@ -2,7 +2,7 @@
// autoload_namespaces.php @generated by Composer // autoload_namespaces.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__)); $vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir); $baseDir = dirname($vendorDir);
return array( return array(

View File

@ -2,7 +2,7 @@
// autoload_psr4.php @generated by Composer // autoload_psr4.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__)); $vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir); $baseDir = dirname($vendorDir);
return array( return array(

View File

@ -2,7 +2,7 @@
// autoload_psr4.php @generated by Composer // autoload_psr4.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__)); $vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir); $baseDir = dirname($vendorDir);
return array( return array(

View File

@ -2,7 +2,7 @@
// autoload_psr4.php @generated by Composer // autoload_psr4.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__)); $vendorDir = dirname(__DIR__);
$baseDir = dirname(dirname($vendorDir)); $baseDir = dirname(dirname($vendorDir));
return array( return array(

View File

@ -2,7 +2,7 @@
// autoload_psr4.php @generated by Composer // autoload_psr4.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__)); $vendorDir = dirname(__DIR__);
$baseDir = $vendorDir; $baseDir = $vendorDir;
return array( return array(

View File

@ -23,38 +23,15 @@ class ComposerAutoloaderInitFilesAutoloadOrder
} }
spl_autoload_register(array('ComposerAutoloaderInitFilesAutoloadOrder', 'loadClassLoader'), true, true); 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')); spl_autoload_unregister(array('ComposerAutoloaderInitFilesAutoloadOrder', 'loadClassLoader'));
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); require __DIR__ . '/autoload_static.php';
if ($useStaticLoader) { \Composer\Autoload\ComposerStaticInitFilesAutoloadOrder::getInitializer($loader)();
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);
}
}
$loader->register(true); $loader->register(true);
if ($useStaticLoader) { $includeFiles = \Composer\Autoload\ComposerStaticInitFilesAutoloadOrder::$files;
$includeFiles = Composer\Autoload\ComposerStaticInitFilesAutoloadOrder::$files;
} else {
$includeFiles = require __DIR__ . '/autoload_files.php';
}
foreach ($includeFiles as $fileIdentifier => $file) { foreach ($includeFiles as $fileIdentifier => $file) {
composerRequireFilesAutoloadOrder($fileIdentifier, $file); composerRequireFilesAutoloadOrder($fileIdentifier, $file);
} }

View File

@ -23,38 +23,15 @@ class ComposerAutoloaderInitFilesAutoload
} }
spl_autoload_register(array('ComposerAutoloaderInitFilesAutoload', 'loadClassLoader'), true, true); 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')); spl_autoload_unregister(array('ComposerAutoloaderInitFilesAutoload', 'loadClassLoader'));
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); require __DIR__ . '/autoload_static.php';
if ($useStaticLoader) { \Composer\Autoload\ComposerStaticInitFilesAutoload::getInitializer($loader)();
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);
}
}
$loader->register(true); $loader->register(true);
if ($useStaticLoader) { $includeFiles = \Composer\Autoload\ComposerStaticInitFilesAutoload::$files;
$includeFiles = Composer\Autoload\ComposerStaticInitFilesAutoload::$files;
} else {
$includeFiles = require __DIR__ . '/autoload_files.php';
}
foreach ($includeFiles as $fileIdentifier => $file) { foreach ($includeFiles as $fileIdentifier => $file) {
composerRequireFilesAutoload($fileIdentifier, $file); composerRequireFilesAutoload($fileIdentifier, $file);
} }

View File

@ -23,42 +23,19 @@ class ComposerAutoloaderInitFilesAutoload
} }
spl_autoload_register(array('ComposerAutoloaderInitFilesAutoload', 'loadClassLoader'), true, true); 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')); spl_autoload_unregister(array('ComposerAutoloaderInitFilesAutoload', 'loadClassLoader'));
$includePaths = require __DIR__ . '/include_paths.php'; $includePaths = require __DIR__ . '/include_paths.php';
$includePaths[] = get_include_path(); $includePaths[] = get_include_path();
set_include_path(implode(PATH_SEPARATOR, $includePaths)); 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()); require __DIR__ . '/autoload_static.php';
if ($useStaticLoader) { \Composer\Autoload\ComposerStaticInitFilesAutoload::getInitializer($loader)();
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);
}
}
$loader->register(true); $loader->register(true);
if ($useStaticLoader) { $includeFiles = \Composer\Autoload\ComposerStaticInitFilesAutoload::$files;
$includeFiles = Composer\Autoload\ComposerStaticInitFilesAutoload::$files;
} else {
$includeFiles = require __DIR__ . '/autoload_files.php';
}
foreach ($includeFiles as $fileIdentifier => $file) { foreach ($includeFiles as $fileIdentifier => $file) {
composerRequireFilesAutoload($fileIdentifier, $file); composerRequireFilesAutoload($fileIdentifier, $file);
} }

View File

@ -23,30 +23,11 @@ class ComposerAutoloaderInitFilesAutoload
} }
spl_autoload_register(array('ComposerAutoloaderInitFilesAutoload', 'loadClassLoader'), true, true); 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')); spl_autoload_unregister(array('ComposerAutoloaderInitFilesAutoload', 'loadClassLoader'));
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); require __DIR__ . '/autoload_static.php';
if ($useStaticLoader) { \Composer\Autoload\ComposerStaticInitFilesAutoload::getInitializer($loader)();
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);
}
}
$loader->register(true); $loader->register(true);

View File

@ -23,30 +23,11 @@ class ComposerAutoloaderInitIncludePath
} }
spl_autoload_register(array('ComposerAutoloaderInitIncludePath', 'loadClassLoader'), true, true); 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')); spl_autoload_unregister(array('ComposerAutoloaderInitIncludePath', 'loadClassLoader'));
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); require __DIR__ . '/autoload_static.php';
if ($useStaticLoader) { \Composer\Autoload\ComposerStaticInitIncludePath::getInitializer($loader)();
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);
}
}
$loader->setUseIncludePath(true); $loader->setUseIncludePath(true);
spl_autoload_register(array('ComposerAutoloaderInitIncludePath', 'autoload'), true, true); spl_autoload_register(array('ComposerAutoloaderInitIncludePath', 'autoload'), true, true);

View File

@ -23,40 +23,17 @@ class ComposerAutoloaderInitTargetDir
} }
spl_autoload_register(array('ComposerAutoloaderInitTargetDir', 'loadClassLoader'), true, true); 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')); spl_autoload_unregister(array('ComposerAutoloaderInitTargetDir', 'loadClassLoader'));
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); require __DIR__ . '/autoload_static.php';
if ($useStaticLoader) { \Composer\Autoload\ComposerStaticInitTargetDir::getInitializer($loader)();
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);
}
}
spl_autoload_register(array('ComposerAutoloaderInitTargetDir', 'autoload'), true, true); spl_autoload_register(array('ComposerAutoloaderInitTargetDir', 'autoload'), true, true);
$loader->register(true); $loader->register(true);
if ($useStaticLoader) { $includeFiles = \Composer\Autoload\ComposerStaticInitTargetDir::$files;
$includeFiles = Composer\Autoload\ComposerStaticInitTargetDir::$files;
} else {
$includeFiles = require __DIR__ . '/autoload_files.php';
}
foreach ($includeFiles as $fileIdentifier => $file) { foreach ($includeFiles as $fileIdentifier => $file) {
composerRequireTargetDir($fileIdentifier, $file); composerRequireTargetDir($fileIdentifier, $file);
} }

View File

@ -2,7 +2,7 @@
// autoload_namespaces.php @generated by Composer // autoload_namespaces.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__)); $vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir); $baseDir = dirname($vendorDir);
return array( return array(

View File

@ -2,7 +2,7 @@
// include_paths.php @generated by Composer // include_paths.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__)); $vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir); $baseDir = dirname($vendorDir);
return array( return array(

View File

@ -2,7 +2,7 @@
// include_paths.php @generated by Composer // include_paths.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__)); $vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir); $baseDir = dirname($vendorDir);
return array( return array(

View File

@ -2,7 +2,7 @@
// include_paths.php @generated by Composer // include_paths.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__)); $vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir); $baseDir = dirname($vendorDir);
return array( return array(

View File

@ -91,7 +91,7 @@ class BinaryInstallerTest extends TestCase
public function executableBinaryProvider() public function executableBinaryProvider()
{ {
$tests = array( return array(
'simple php file' => array(<<<'EOL' 'simple php file' => array(<<<'EOL'
<?php <?php
@ -108,21 +108,14 @@ EOL
'phar file' => array( 'phar file' => array(
base64_decode('IyEvdXNyL2Jpbi9lbnYgcGhwCjw/cGhwCgpQaGFyOjptYXBQaGFyKCd0ZXN0LnBoYXInKTsKCnJlcXVpcmUgJ3BoYXI6Ly90ZXN0LnBoYXIvcnVuLnBocCc7CgpfX0hBTFRfQ09NUElMRVIoKTsgPz4NCj4AAAABAAAAEQAAAAEACQAAAHRlc3QucGhhcgAAAAAHAAAAcnVuLnBocCoAAADb9n9hKgAAAMUDDWGkAQAAAAAAADw/cGhwIGVjaG8gInN1Y2Nlc3MgIi4kX1NFUlZFUlsiYXJndiJdWzFdO1SOC0IE3+UN0yzrHIwyspp9slhmAgAAAEdCTUI=') base64_decode('IyEvdXNyL2Jpbi9lbnYgcGhwCjw/cGhwCgpQaGFyOjptYXBQaGFyKCd0ZXN0LnBoYXInKTsKCnJlcXVpcmUgJ3BoYXI6Ly90ZXN0LnBoYXIvcnVuLnBocCc7CgpfX0hBTFRfQ09NUElMRVIoKTsgPz4NCj4AAAABAAAAEQAAAAEACQAAAHRlc3QucGhhcgAAAAAHAAAAcnVuLnBocCoAAADb9n9hKgAAAMUDDWGkAQAAAAAAADw/cGhwIGVjaG8gInN1Y2Nlc3MgIi4kX1NFUlZFUlsiYXJndiJdWzFdO1SOC0IE3+UN0yzrHIwyspp9slhmAgAAAEdCTUI=')
), ),
); 'shebang with strict types declare' => array(<<<'EOL'
if (PHP_VERSION_ID >= 70000) {
$tests += array(
'shebang with strict types declare' => array(<<<'EOL'
#!/usr/bin/env php #!/usr/bin/env php
<?php declare(strict_types=1); <?php declare(strict_types=1);
echo 'success '.$_SERVER['argv'][1]; echo 'success '.$_SERVER['argv'][1];
EOL EOL
), ),
); );
}
return $tests;
} }
/** /**

View File

@ -128,7 +128,7 @@ class InstallerTest extends TestCase
$lockJsonMock->expects($this->any()) $lockJsonMock->expects($this->any())
->method('write') ->method('write')
->will($this->returnCallback(function ($value, $options = 0) use (&$lockData) { ->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; $tempLockData = null;
@ -339,7 +339,7 @@ class InstallerTest extends TestCase
$repositoryManager->setLocalRepository(new InstalledFilesystemRepositoryMock($jsonMock)); $repositoryManager->setLocalRepository(new InstalledFilesystemRepositoryMock($jsonMock));
// emulate a writable lock file // 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 = $this->getMockBuilder('Composer\Json\JsonFile')->disableOriginalConstructor()->getMock();
$lockJsonMock->expects($this->any()) $lockJsonMock->expects($this->any())
->method('read') ->method('read')
@ -354,7 +354,7 @@ class InstallerTest extends TestCase
$lockJsonMock->expects($this->any()) $lockJsonMock->expects($this->any())
->method('write') ->method('write')
->will($this->returnCallback(function ($value, $options = 0) use (&$lockData) { ->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) { if ($expectLock) {

View File

@ -312,7 +312,7 @@ class JsonFileTest extends TestCase
$data = "\\"; $data = "\\";
$this->assertJsonFormat('"\\\\\\/ƌ"', $data, JsonFile::JSON_UNESCAPED_UNICODE); $this->assertJsonFormat('"\\\\\\/ƌ"', $data, JSON_UNESCAPED_UNICODE);
} }
public function testEscapedSlashes() public function testEscapedSlashes()

View File

@ -29,6 +29,7 @@ class JsonFormatterTest extends TestCase
$backslash = chr(92); $backslash = chr(92);
$data = '"' . $backslash . $backslash . $backslash . 'u0119"'; $data = '"' . $backslash . $backslash . $backslash . 'u0119"';
$expected = '"' . $backslash . $backslash . 'ę"'; $expected = '"' . $backslash . $backslash . 'ę"';
/** @phpstan-ignore-next-line */
$this->assertEquals($expected, JsonFormatter::format($data, true, true)); $this->assertEquals($expected, JsonFormatter::format($data, true, true));
} }
@ -43,6 +44,7 @@ class JsonFormatterTest extends TestCase
} }
$escaped = '"\ud83d\ude00"'; $escaped = '"\ud83d\ude00"';
/** @phpstan-ignore-next-line */
$this->assertEquals($escaped, JsonFormatter::format($escaped, true, true)); $this->assertEquals($escaped, JsonFormatter::format($escaped, true, true));
} }
} }

View File

@ -29,6 +29,7 @@ class TlsHelperTest extends TestCase
$certificate['subject']['commonName'] = $expectedCn = array_shift($certNames); $certificate['subject']['commonName'] = $expectedCn = array_shift($certNames);
$certificate['extensions']['subjectAltName'] = $certNames ? 'DNS:'.implode(',DNS:', $certNames) : ''; $certificate['extensions']['subjectAltName'] = $certNames ? 'DNS:'.implode(',DNS:', $certNames) : '';
// @phpstan-ignore-next-line
$result = TlsHelper::checkCertificateHost($certificate, $hostname, $foundCn); $result = TlsHelper::checkCertificateHost($certificate, $hostname, $foundCn);
if (true === $expectedResult) { if (true === $expectedResult) {
@ -71,6 +72,7 @@ class TlsHelperTest extends TestCase
$certificate['subject']['commonName'] = 'example.net'; $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'; $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); $names = TlsHelper::getCertificateNames($certificate);
$this->assertSame('example.net', $names['cn']); $this->assertSame('example.net', $names['cn']);