Make use of some new PHP features
parent
86fb8d4412
commit
32852304d0
|
@ -16,12 +16,13 @@ $finder = PhpCsFixer\Finder::create()
|
||||||
->in(__DIR__.'/tests')
|
->in(__DIR__.'/tests')
|
||||||
->name('*.php')
|
->name('*.php')
|
||||||
->notPath('Fixtures')
|
->notPath('Fixtures')
|
||||||
|
->notPath(__DIR__.'/src/Composer/Autoload/ClassLoader.php')
|
||||||
|
->notPath(__DIR__.'/src/Composer/InstalledVersions.php')
|
||||||
;
|
;
|
||||||
|
|
||||||
$config = new PhpCsFixer\Config();
|
$config = new PhpCsFixer\Config();
|
||||||
return $config->setRules([
|
return $config->setRules([
|
||||||
'@PSR2' => true,
|
'@PSR2' => true,
|
||||||
'array_syntax' => array('syntax' => 'long'),
|
|
||||||
'binary_operator_spaces' => true,
|
'binary_operator_spaces' => true,
|
||||||
'blank_line_before_statement' => array('statements' => array('declare', 'return')),
|
'blank_line_before_statement' => array('statements' => array('declare', 'return')),
|
||||||
'cast_spaces' => array('space' => 'single'),
|
'cast_spaces' => array('space' => 'single'),
|
||||||
|
@ -59,6 +60,18 @@ return $config->setRules([
|
||||||
//'global_namespace_import' => ['import_classes' => true],
|
//'global_namespace_import' => ['import_classes' => true],
|
||||||
'no_leading_import_slash' => true,
|
'no_leading_import_slash' => true,
|
||||||
'single_import_per_statement' => true,
|
'single_import_per_statement' => true,
|
||||||
|
|
||||||
|
// PHP 7.2 migration
|
||||||
|
// TODO later once 2.2 is more stable
|
||||||
|
// 'array_syntax' => true,
|
||||||
|
// 'list_syntax' => true,
|
||||||
|
'visibility_required' => ['elements' => ['property', 'method', /* TODO 'const' but need to review them all */]],
|
||||||
|
'non_printable_character' => true,
|
||||||
|
'combine_nested_dirname' => true,
|
||||||
|
'random_api_migration' => true,
|
||||||
|
'ternary_to_null_coalescing' => true,
|
||||||
|
//'declare_strict_types' => true,
|
||||||
|
//'void_return' => true,
|
||||||
])
|
])
|
||||||
->setUsingCache(true)
|
->setUsingCache(true)
|
||||||
->setRiskyAllowed(true)
|
->setRiskyAllowed(true)
|
||||||
|
|
|
@ -263,7 +263,7 @@ EOT
|
||||||
$data = $this->config->all();
|
$data = $this->config->all();
|
||||||
if (Preg::isMatch('/^repos?(?:itories)?(?:\.(.+))?/', $settingKey, $matches)) {
|
if (Preg::isMatch('/^repos?(?:itories)?(?:\.(.+))?/', $settingKey, $matches)) {
|
||||||
if (!isset($matches[1]) || $matches[1] === '') {
|
if (!isset($matches[1]) || $matches[1] === '') {
|
||||||
$value = isset($data['repositories']) ? $data['repositories'] : array();
|
$value = $data['repositories'] ?? array();
|
||||||
} else {
|
} else {
|
||||||
if (!isset($data['repositories'][$matches[1]])) {
|
if (!isset($data['repositories'][$matches[1]])) {
|
||||||
throw new \InvalidArgumentException('There is no '.$matches[1].' repository defined');
|
throw new \InvalidArgumentException('There is no '.$matches[1].' repository defined');
|
||||||
|
@ -699,7 +699,7 @@ EOT
|
||||||
$currentValue = $this->configFile->read();
|
$currentValue = $this->configFile->read();
|
||||||
$bits = explode('.', $settingKey);
|
$bits = explode('.', $settingKey);
|
||||||
foreach ($bits as $bit) {
|
foreach ($bits as $bit) {
|
||||||
$currentValue = isset($currentValue[$bit]) ? $currentValue[$bit] : null;
|
$currentValue = $currentValue[$bit] ?? null;
|
||||||
}
|
}
|
||||||
if (is_array($currentValue)) {
|
if (is_array($currentValue)) {
|
||||||
$value = array_merge($currentValue, $value);
|
$value = array_merge($currentValue, $value);
|
||||||
|
@ -877,7 +877,7 @@ EOT
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$rawVal = isset($rawContents[$key]) ? $rawContents[$key] : null;
|
$rawVal = $rawContents[$key] ?? null;
|
||||||
|
|
||||||
if (is_array($value) && (!is_numeric(key($value)) || ($key === 'repositories' && null === $k))) {
|
if (is_array($value) && (!is_numeric(key($value)) || ($key === 'repositories' && null === $k))) {
|
||||||
$k .= Preg::replace('{^config\.}', '', $key . '.');
|
$k .= Preg::replace('{^config\.}', '', $key . '.');
|
||||||
|
|
|
@ -447,7 +447,7 @@ EOT
|
||||||
|
|
||||||
return '<comment>'.$version['version'].'</comment> '.
|
return '<comment>'.$version['version'].'</comment> '.
|
||||||
'libz <comment>'.(!empty($version['libz_version']) ? $version['libz_version'] : 'missing').'</comment> '.
|
'libz <comment>'.(!empty($version['libz_version']) ? $version['libz_version'] : 'missing').'</comment> '.
|
||||||
'ssl <comment>'.(isset($version['ssl_version']) ? $version['ssl_version'] : 'missing').'</comment>';
|
'ssl <comment>'.($version['ssl_version'] ?? 'missing').'</comment>';
|
||||||
}
|
}
|
||||||
|
|
||||||
return '<error>missing, using php streams fallback, which reduces performance</error>';
|
return '<error>missing, using php streams fallback, which reduces performance</error>';
|
||||||
|
|
|
@ -104,7 +104,7 @@ EOT
|
||||||
private function handlePackage(CompletePackageInterface $package, $showHomepage, $showOnly)
|
private function handlePackage(CompletePackageInterface $package, $showHomepage, $showOnly)
|
||||||
{
|
{
|
||||||
$support = $package->getSupport();
|
$support = $package->getSupport();
|
||||||
$url = isset($support['source']) ? $support['source'] : $package->getSourceUrl();
|
$url = $support['source'] ?? $package->getSourceUrl();
|
||||||
if (!$url || $showHomepage) {
|
if (!$url || $showHomepage) {
|
||||||
$url = $package->getHomepage();
|
$url = $package->getHomepage();
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,7 +107,7 @@ EOT
|
||||||
}
|
}
|
||||||
$nameLength += 1;
|
$nameLength += 1;
|
||||||
foreach ($results as $result) {
|
foreach ($results as $result) {
|
||||||
$description = isset($result['description']) ? $result['description'] : '';
|
$description = $result['description'] ?? '';
|
||||||
$warning = !empty($result['abandoned']) ? '<warning>! Abandoned !</warning> ' : '';
|
$warning = !empty($result['abandoned']) ? '<warning>! Abandoned !</warning> ' : '';
|
||||||
$remaining = $width - $nameLength - strlen($warning) - 2;
|
$remaining = $width - $nameLength - strlen($warning) - 2;
|
||||||
if (strlen($description) > $remaining) {
|
if (strlen($description) > $remaining) {
|
||||||
|
|
|
@ -213,7 +213,7 @@ EOT
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
$tempFilename = $tmpDir . '/' . basename($localFilename, '.phar').'-temp'.rand(0, 10000000).'.phar';
|
$tempFilename = $tmpDir . '/' . basename($localFilename, '.phar').'-temp'.random_int(0, 10000000).'.phar';
|
||||||
$backupFile = sprintf(
|
$backupFile = sprintf(
|
||||||
'%s/%s-%s%s',
|
'%s/%s-%s%s',
|
||||||
$rollbackDir,
|
$rollbackDir,
|
||||||
|
|
|
@ -204,7 +204,7 @@ class Compiler
|
||||||
private function getRelativeFilePath($file)
|
private function getRelativeFilePath($file)
|
||||||
{
|
{
|
||||||
$realPath = $file->getRealPath();
|
$realPath = $file->getRealPath();
|
||||||
$pathPrefix = dirname(dirname(__DIR__)).DIRECTORY_SEPARATOR;
|
$pathPrefix = dirname(__DIR__, 2).DIRECTORY_SEPARATOR;
|
||||||
|
|
||||||
$pos = strpos($realPath, $pathPrefix);
|
$pos = strpos($realPath, $pathPrefix);
|
||||||
$relativePath = ($pos !== false) ? substr_replace($realPath, '', $pos, strlen($pathPrefix)) : $realPath;
|
$relativePath = ($pos !== false) ? substr_replace($realPath, '', $pos, strlen($pathPrefix)) : $realPath;
|
||||||
|
|
|
@ -461,7 +461,7 @@ class Config
|
||||||
{
|
{
|
||||||
$this->get($key);
|
$this->get($key);
|
||||||
|
|
||||||
return isset($this->sourceOfConfigValue[$key]) ? $this->sourceOfConfigValue[$key] : self::SOURCE_UNKNOWN;
|
return $this->sourceOfConfigValue[$key] ?? self::SOURCE_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -256,7 +256,7 @@ class Decisions implements \Iterator, \Countable
|
||||||
{
|
{
|
||||||
$packageId = abs($literal);
|
$packageId = abs($literal);
|
||||||
|
|
||||||
$previousDecision = isset($this->decisionMap[$packageId]) ? $this->decisionMap[$packageId] : null;
|
$previousDecision = $this->decisionMap[$packageId] ?? null;
|
||||||
if ($previousDecision != 0) {
|
if ($previousDecision != 0) {
|
||||||
$literalString = $this->pool->literalToPrettyString($literal, array());
|
$literalString = $this->pool->literalToPrettyString($literal, array());
|
||||||
$package = $this->pool->literalToPackage($literal);
|
$package = $this->pool->literalToPackage($literal);
|
||||||
|
|
|
@ -376,7 +376,7 @@ class PoolBuilder
|
||||||
if ($repository instanceof PlatformRepository || $repository === $request->getLockedRepository()) {
|
if ($repository instanceof PlatformRepository || $repository === $request->getLockedRepository()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$result = $repository->loadPackages($packageBatch, $this->acceptableStabilities, $this->stabilityFlags, isset($this->loadedPerRepo[$repoIndex]) ? $this->loadedPerRepo[$repoIndex] : array());
|
$result = $repository->loadPackages($packageBatch, $this->acceptableStabilities, $this->stabilityFlags, $this->loadedPerRepo[$repoIndex] ?? array());
|
||||||
|
|
||||||
foreach ($result['namesFound'] as $name) {
|
foreach ($result['namesFound'] as $name) {
|
||||||
// avoid loading the same package again from other repositories once it has been found
|
// avoid loading the same package again from other repositories once it has been found
|
||||||
|
|
|
@ -260,7 +260,7 @@ class PathDownloader extends FileDownloader implements VcsCapableDownloaderInter
|
||||||
$currentStrategy = self::STRATEGY_MIRROR;
|
$currentStrategy = self::STRATEGY_MIRROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
$symlinkOption = isset($transportOptions['symlink']) ? $transportOptions['symlink'] : null;
|
$symlinkOption = $transportOptions['symlink'] ?? null;
|
||||||
|
|
||||||
if (true === $symlinkOption) {
|
if (true === $symlinkOption) {
|
||||||
$currentStrategy = self::STRATEGY_SYMLINK;
|
$currentStrategy = self::STRATEGY_SYMLINK;
|
||||||
|
|
|
@ -428,10 +428,10 @@ class EventDispatcher
|
||||||
if (is_string($params)) {
|
if (is_string($params)) {
|
||||||
$this->addListener($eventName, array($subscriber, $params));
|
$this->addListener($eventName, array($subscriber, $params));
|
||||||
} elseif (is_string($params[0])) {
|
} elseif (is_string($params[0])) {
|
||||||
$this->addListener($eventName, array($subscriber, $params[0]), isset($params[1]) ? $params[1] : 0);
|
$this->addListener($eventName, array($subscriber, $params[0]), $params[1] ?? 0);
|
||||||
} else {
|
} else {
|
||||||
foreach ($params as $listener) {
|
foreach ($params as $listener) {
|
||||||
$this->addListener($eventName, array($subscriber, $listener[0]), isset($listener[1]) ? $listener[1] : 0);
|
$this->addListener($eventName, array($subscriber, $listener[0]), $listener[1] ?? 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -248,7 +248,7 @@ class Factory
|
||||||
*/
|
*/
|
||||||
public static function getComposerFile()
|
public static function getComposerFile()
|
||||||
{
|
{
|
||||||
return trim(Platform::getEnv('COMPOSER')) ?: './composer.json';
|
return trim((string) Platform::getEnv('COMPOSER')) ?: './composer.json';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -185,7 +185,7 @@ class ArrayLoader implements LoaderInterface
|
||||||
}
|
}
|
||||||
$package->setSourceType($config['source']['type']);
|
$package->setSourceType($config['source']['type']);
|
||||||
$package->setSourceUrl($config['source']['url']);
|
$package->setSourceUrl($config['source']['url']);
|
||||||
$package->setSourceReference(isset($config['source']['reference']) ? $config['source']['reference'] : null);
|
$package->setSourceReference($config['source']['reference'] ?? null);
|
||||||
if (isset($config['source']['mirrors'])) {
|
if (isset($config['source']['mirrors'])) {
|
||||||
$package->setSourceMirrors($config['source']['mirrors']);
|
$package->setSourceMirrors($config['source']['mirrors']);
|
||||||
}
|
}
|
||||||
|
@ -202,8 +202,8 @@ class ArrayLoader implements LoaderInterface
|
||||||
}
|
}
|
||||||
$package->setDistType($config['dist']['type']);
|
$package->setDistType($config['dist']['type']);
|
||||||
$package->setDistUrl($config['dist']['url']);
|
$package->setDistUrl($config['dist']['url']);
|
||||||
$package->setDistReference(isset($config['dist']['reference']) ? $config['dist']['reference'] : null);
|
$package->setDistReference($config['dist']['reference'] ?? null);
|
||||||
$package->setDistSha1Checksum(isset($config['dist']['shasum']) ? $config['dist']['shasum'] : null);
|
$package->setDistSha1Checksum($config['dist']['shasum'] ?? null);
|
||||||
if (isset($config['dist']['mirrors'])) {
|
if (isset($config['dist']['mirrors'])) {
|
||||||
$package->setDistMirrors($config['dist']['mirrors']);
|
$package->setDistMirrors($config['dist']['mirrors']);
|
||||||
}
|
}
|
||||||
|
|
|
@ -234,7 +234,7 @@ class Locker
|
||||||
'__root__',
|
'__root__',
|
||||||
'1.0.0',
|
'1.0.0',
|
||||||
Link::TYPE_REQUIRE,
|
Link::TYPE_REQUIRE,
|
||||||
isset($lockData['platform']) ? $lockData['platform'] : array()
|
$lockData['platform'] ?? array()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,7 +243,7 @@ class Locker
|
||||||
'__root__',
|
'__root__',
|
||||||
'1.0.0',
|
'1.0.0',
|
||||||
Link::TYPE_REQUIRE,
|
Link::TYPE_REQUIRE,
|
||||||
isset($lockData['platform-dev']) ? $lockData['platform-dev'] : array()
|
$lockData['platform-dev'] ?? array()
|
||||||
);
|
);
|
||||||
|
|
||||||
$requirements = array_merge($requirements, $devRequirements);
|
$requirements = array_merge($requirements, $devRequirements);
|
||||||
|
@ -259,7 +259,7 @@ class Locker
|
||||||
{
|
{
|
||||||
$lockData = $this->getLockData();
|
$lockData = $this->getLockData();
|
||||||
|
|
||||||
return isset($lockData['minimum-stability']) ? $lockData['minimum-stability'] : 'stable';
|
return $lockData['minimum-stability'] ?? 'stable';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -269,7 +269,7 @@ class Locker
|
||||||
{
|
{
|
||||||
$lockData = $this->getLockData();
|
$lockData = $this->getLockData();
|
||||||
|
|
||||||
return isset($lockData['stability-flags']) ? $lockData['stability-flags'] : array();
|
return $lockData['stability-flags'] ?? array();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -281,7 +281,7 @@ class Locker
|
||||||
|
|
||||||
// return null if not set to allow caller logic to choose the
|
// return null if not set to allow caller logic to choose the
|
||||||
// right behavior since old lock files have no prefer-stable
|
// right behavior since old lock files have no prefer-stable
|
||||||
return isset($lockData['prefer-stable']) ? $lockData['prefer-stable'] : null;
|
return $lockData['prefer-stable'] ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -293,7 +293,7 @@ class Locker
|
||||||
|
|
||||||
// return null if not set to allow caller logic to choose the
|
// return null if not set to allow caller logic to choose the
|
||||||
// right behavior since old lock files have no prefer-lowest
|
// right behavior since old lock files have no prefer-lowest
|
||||||
return isset($lockData['prefer-lowest']) ? $lockData['prefer-lowest'] : null;
|
return $lockData['prefer-lowest'] ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -303,7 +303,7 @@ class Locker
|
||||||
{
|
{
|
||||||
$lockData = $this->getLockData();
|
$lockData = $this->getLockData();
|
||||||
|
|
||||||
return isset($lockData['platform-overrides']) ? $lockData['platform-overrides'] : array();
|
return $lockData['platform-overrides'] ?? array();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -315,7 +315,7 @@ class Locker
|
||||||
{
|
{
|
||||||
$lockData = $this->getLockData();
|
$lockData = $this->getLockData();
|
||||||
|
|
||||||
return isset($lockData['aliases']) ? $lockData['aliases'] : array();
|
return $lockData['aliases'] ?? array();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -442,7 +442,7 @@ class Locker
|
||||||
unset($spec['version_normalized']);
|
unset($spec['version_normalized']);
|
||||||
|
|
||||||
// always move time to the end of the package definition
|
// always move time to the end of the package definition
|
||||||
$time = isset($spec['time']) ? $spec['time'] : null;
|
$time = $spec['time'] ?? null;
|
||||||
unset($spec['time']);
|
unset($spec['time']);
|
||||||
if ($package->isDev() && $package->getInstallationSource() === 'source') {
|
if ($package->isDev() && $package->getInstallationSource() === 'source') {
|
||||||
// use the exact commit time of the current reference if it's a dev package
|
// use the exact commit time of the current reference if it's a dev package
|
||||||
|
|
|
@ -623,8 +623,8 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
|
||||||
}
|
}
|
||||||
$result[$candidate['name']] = array(
|
$result[$candidate['name']] = array(
|
||||||
'name' => $candidate['name'],
|
'name' => $candidate['name'],
|
||||||
'description' => isset($candidate['description']) ? $candidate['description'] : '',
|
'description' => $candidate['description'] ?? '',
|
||||||
'type' => isset($candidate['type']) ? $candidate['type'] : '',
|
'type' => $candidate['type'] ?? '',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -900,7 +900,7 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
|
||||||
$lastModified = null;
|
$lastModified = null;
|
||||||
if ($contents = $this->cache->read($cacheKey)) {
|
if ($contents = $this->cache->read($cacheKey)) {
|
||||||
$contents = json_decode($contents, true);
|
$contents = json_decode($contents, true);
|
||||||
$lastModified = isset($contents['last-modified']) ? $contents['last-modified'] : null;
|
$lastModified = $contents['last-modified'] ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$promises[] = $this->asyncFetchFile($url, $cacheKey, $lastModified)
|
$promises[] = $this->asyncFetchFile($url, $cacheKey, $lastModified)
|
||||||
|
@ -1275,7 +1275,7 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
|
||||||
|
|
||||||
return $packageInstances;
|
return $packageInstances;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
throw new \RuntimeException('Could not load packages '.(isset($packages[0]['name']) ? $packages[0]['name'] : json_encode($packages)).' in '.$this->getRepoName().($source ? ' from '.$source : '').': ['.get_class($e).'] '.$e->getMessage(), 0, $e);
|
throw new \RuntimeException('Could not load packages '.($packages[0]['name'] ?? json_encode($packages)).' in '.$this->getRepoName().($source ? ' from '.$source : '').': ['.get_class($e).'] '.$e->getMessage(), 0, $e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -120,7 +120,7 @@ class PathRepository extends ArrayRepository implements ConfigurableRepositoryIn
|
||||||
$this->process = new ProcessExecutor($io);
|
$this->process = new ProcessExecutor($io);
|
||||||
$this->versionGuesser = new VersionGuesser($config, $this->process, new VersionParser());
|
$this->versionGuesser = new VersionGuesser($config, $this->process, new VersionParser());
|
||||||
$this->repoConfig = $repoConfig;
|
$this->repoConfig = $repoConfig;
|
||||||
$this->options = isset($repoConfig['options']) ? $repoConfig['options'] : array();
|
$this->options = $repoConfig['options'] ?? array();
|
||||||
if (!isset($this->options['relative'])) {
|
if (!isset($this->options['relative'])) {
|
||||||
$filesystem = new Filesystem();
|
$filesystem = new Filesystem();
|
||||||
$this->options['relative'] = !$filesystem->isAbsolutePath($this->url);
|
$this->options['relative'] = !$filesystem->isAbsolutePath($this->url);
|
||||||
|
|
|
@ -167,7 +167,7 @@ abstract class VcsDriver implements VcsDriverInterface
|
||||||
*/
|
*/
|
||||||
protected function getContents($url)
|
protected function getContents($url)
|
||||||
{
|
{
|
||||||
$options = isset($this->repoConfig['options']) ? $this->repoConfig['options'] : array();
|
$options = $this->repoConfig['options'] ?? array();
|
||||||
|
|
||||||
return $this->httpDownloader->get($url, $options);
|
return $this->httpDownloader->get($url, $options);
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,7 +92,7 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt
|
||||||
|
|
||||||
$this->url = $repoConfig['url'];
|
$this->url = $repoConfig['url'];
|
||||||
$this->io = $io;
|
$this->io = $io;
|
||||||
$this->type = isset($repoConfig['type']) ? $repoConfig['type'] : 'vcs';
|
$this->type = $repoConfig['type'] ?? 'vcs';
|
||||||
$this->isVerbose = $io->isVerbose();
|
$this->isVerbose = $io->isVerbose();
|
||||||
$this->isVeryVerbose = $io->isVeryVerbose();
|
$this->isVeryVerbose = $io->isVeryVerbose();
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
|
@ -290,7 +290,7 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$tagPackageName = $this->packageName ?: (isset($data['name']) ? $data['name'] : '');
|
$tagPackageName = $this->packageName ?: ($data['name'] ?? '');
|
||||||
if ($existingPackage = $this->findPackage($tagPackageName, $data['version_normalized'])) {
|
if ($existingPackage = $this->findPackage($tagPackageName, $data['version_normalized'])) {
|
||||||
if ($isVeryVerbose) {
|
if ($isVeryVerbose) {
|
||||||
$this->io->writeError('<warning>Skipped tag '.$tag.', it conflicts with an another tag ('.$existingPackage->getPrettyVersion().') as both resolve to '.$data['version_normalized'].' internally</warning>');
|
$this->io->writeError('<warning>Skipped tag '.$tag.', it conflicts with an another tag ('.$existingPackage->getPrettyVersion().') as both resolve to '.$data['version_normalized'].' internally</warning>');
|
||||||
|
@ -439,7 +439,7 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt
|
||||||
// keep the name of the main identifier for all packages
|
// keep the name of the main identifier for all packages
|
||||||
// this ensures that a package can be renamed in one place and that all old tags
|
// this ensures that a package can be renamed in one place and that all old tags
|
||||||
// will still be installable using that new name without requiring re-tagging
|
// will still be installable using that new name without requiring re-tagging
|
||||||
$dataPackageName = isset($data['name']) ? $data['name'] : null;
|
$dataPackageName = $data['name'] ?? null;
|
||||||
$data['name'] = $this->packageName ?: $dataPackageName;
|
$data['name'] = $this->packageName ?: $dataPackageName;
|
||||||
|
|
||||||
if (!isset($data['dist'])) {
|
if (!isset($data['dist'])) {
|
||||||
|
|
|
@ -159,8 +159,8 @@ class ConfigValidator
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for commit references
|
// check for commit references
|
||||||
$require = isset($manifest['require']) ? $manifest['require'] : array();
|
$require = $manifest['require'] ?? array();
|
||||||
$requireDev = isset($manifest['require-dev']) ? $manifest['require-dev'] : array();
|
$requireDev = $manifest['require-dev'] ?? array();
|
||||||
$packages = array_merge($require, $requireDev);
|
$packages = array_merge($require, $requireDev);
|
||||||
foreach ($packages as $package => $version) {
|
foreach ($packages as $package => $version) {
|
||||||
if (Preg::isMatch('/#/', $version)) {
|
if (Preg::isMatch('/#/', $version)) {
|
||||||
|
@ -172,8 +172,8 @@ class ConfigValidator
|
||||||
}
|
}
|
||||||
|
|
||||||
// report scripts-descriptions for non-existent scripts
|
// report scripts-descriptions for non-existent scripts
|
||||||
$scriptsDescriptions = isset($manifest['scripts-descriptions']) ? $manifest['scripts-descriptions'] : array();
|
$scriptsDescriptions = $manifest['scripts-descriptions'] ?? array();
|
||||||
$scripts = isset($manifest['scripts']) ? $manifest['scripts'] : array();
|
$scripts = $manifest['scripts'] ?? array();
|
||||||
foreach ($scriptsDescriptions as $scriptName => $scriptDescription) {
|
foreach ($scriptsDescriptions as $scriptName => $scriptDescription) {
|
||||||
if (!array_key_exists($scriptName, $scripts)) {
|
if (!array_key_exists($scriptName, $scripts)) {
|
||||||
$warnings[] = sprintf(
|
$warnings[] = sprintf(
|
||||||
|
|
|
@ -91,7 +91,7 @@ class RemoteFilesystem
|
||||||
// handle the other externally set options normally.
|
// handle the other externally set options normally.
|
||||||
$this->options = array_replace_recursive($this->options, $options);
|
$this->options = array_replace_recursive($this->options, $options);
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
$this->authHelper = isset($authHelper) ? $authHelper : new AuthHelper($io, $config);
|
$this->authHelper = $authHelper ?? new AuthHelper($io, $config);
|
||||||
$this->proxyManager = ProxyManager::getInstance();
|
$this->proxyManager = ProxyManager::getInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -531,7 +531,7 @@ class RemoteFilesystem
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.php.net/manual/en/reserved.variables.httpresponseheader.php
|
// https://www.php.net/manual/en/reserved.variables.httpresponseheader.php
|
||||||
$responseHeaders = isset($http_response_header) ? $http_response_header : array();
|
$responseHeaders = $http_response_header ?? array();
|
||||||
|
|
||||||
if (null !== $e) {
|
if (null !== $e) {
|
||||||
throw $e;
|
throw $e;
|
||||||
|
|
|
@ -56,8 +56,8 @@ class PoolOptimizerTest extends TestCase
|
||||||
$request->requireName($package, $parser->parseConstraints($constraint));
|
$request->requireName($package, $parser->parseConstraints($constraint));
|
||||||
}
|
}
|
||||||
|
|
||||||
$preferStable = isset($requestData['preferStable']) ? $requestData['preferStable'] : false;
|
$preferStable = $requestData['preferStable'] ?? false;
|
||||||
$preferLowest = isset($requestData['preferLowest']) ? $requestData['preferLowest'] : false;
|
$preferLowest = $requestData['preferLowest'] ?? false;
|
||||||
|
|
||||||
$pool = new Pool($packagesBefore);
|
$pool = new Pool($packagesBefore);
|
||||||
$poolOptimizer = new PoolOptimizer(new DefaultPolicy($preferStable, $preferLowest));
|
$poolOptimizer = new PoolOptimizer(new DefaultPolicy($preferStable, $preferLowest));
|
||||||
|
|
|
@ -142,9 +142,9 @@ class InstallerTest extends TestCase
|
||||||
$output = str_replace("\r", '', $io->getOutput());
|
$output = str_replace("\r", '', $io->getOutput());
|
||||||
$this->assertEquals(0, $result, $output);
|
$this->assertEquals(0, $result, $output);
|
||||||
|
|
||||||
$expectedInstalled = isset($options['install']) ? $options['install'] : array();
|
$expectedInstalled = $options['install'] ?? array();
|
||||||
$expectedUpdated = isset($options['update']) ? $options['update'] : array();
|
$expectedUpdated = $options['update'] ?? array();
|
||||||
$expectedUninstalled = isset($options['uninstall']) ? $options['uninstall'] : array();
|
$expectedUninstalled = $options['uninstall'] ?? array();
|
||||||
|
|
||||||
$installed = $installationManager->getInstalledPackages();
|
$installed = $installationManager->getInstalledPackages();
|
||||||
$this->assertEquals($this->makePackagesComparable($expectedInstalled), $this->makePackagesComparable($installed));
|
$this->assertEquals($this->makePackagesComparable($expectedInstalled), $this->makePackagesComparable($installed));
|
||||||
|
@ -575,8 +575,8 @@ class InstallerTest extends TestCase
|
||||||
if (!empty($testData['EXPECT-INSTALLED'])) {
|
if (!empty($testData['EXPECT-INSTALLED'])) {
|
||||||
$expectInstalled = JsonFile::parseJson($testData['EXPECT-INSTALLED']);
|
$expectInstalled = JsonFile::parseJson($testData['EXPECT-INSTALLED']);
|
||||||
}
|
}
|
||||||
$expectOutput = isset($testData['EXPECT-OUTPUT']) ? $testData['EXPECT-OUTPUT'] : null;
|
$expectOutput = $testData['EXPECT-OUTPUT'] ?? null;
|
||||||
$expectOutputOptimized = isset($testData['EXPECT-OUTPUT-OPTIMIZED']) ? $testData['EXPECT-OUTPUT-OPTIMIZED'] : null;
|
$expectOutputOptimized = $testData['EXPECT-OUTPUT-OPTIMIZED'] ?? null;
|
||||||
$expect = $testData['EXPECT'];
|
$expect = $testData['EXPECT'];
|
||||||
if (!empty($testData['EXPECT-EXCEPTION'])) {
|
if (!empty($testData['EXPECT-EXCEPTION'])) {
|
||||||
$expectResult = $testData['EXPECT-EXCEPTION'];
|
$expectResult = $testData['EXPECT-EXCEPTION'];
|
||||||
|
|
|
@ -73,7 +73,7 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase
|
||||||
$root = sys_get_temp_dir();
|
$root = sys_get_temp_dir();
|
||||||
|
|
||||||
do {
|
do {
|
||||||
$unique = $root . DIRECTORY_SEPARATOR . uniqid('composer-test-' . rand(1000, 9000));
|
$unique = $root . DIRECTORY_SEPARATOR . uniqid('composer-test-' . random_int(1000, 9000));
|
||||||
|
|
||||||
if (!file_exists($unique) && Silencer::call('mkdir', $unique, 0777)) {
|
if (!file_exists($unique) && Silencer::call('mkdir', $unique, 0777)) {
|
||||||
return realpath($unique);
|
return realpath($unique);
|
||||||
|
|
Loading…
Reference in New Issue