diff --git a/composer.lock b/composer.lock index d1c3e2680..cdfb70766 100644 --- a/composer.lock +++ b/composer.lock @@ -880,16 +880,16 @@ }, { "name": "symfony/console", - "version": "v5.4.9", + "version": "v5.4.10", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "829d5d1bf60b2efeb0887b7436873becc71a45eb" + "reference": "4d671ab4ddac94ee439ea73649c69d9d200b5000" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/829d5d1bf60b2efeb0887b7436873becc71a45eb", - "reference": "829d5d1bf60b2efeb0887b7436873becc71a45eb", + "url": "https://api.github.com/repos/symfony/console/zipball/4d671ab4ddac94ee439ea73649c69d9d200b5000", + "reference": "4d671ab4ddac94ee439ea73649c69d9d200b5000", "shasum": "" }, "require": { @@ -959,7 +959,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v5.4.9" + "source": "https://github.com/symfony/console/tree/v5.4.10" }, "funding": [ { @@ -975,11 +975,11 @@ "type": "tidelift" } ], - "time": "2022-05-18T06:17:34+00:00" + "time": "2022-06-26T13:00:04+00:00" }, { "name": "symfony/deprecation-contracts", - "version": "v2.5.1", + "version": "v2.5.2", "source": { "type": "git", "url": "https://github.com/symfony/deprecation-contracts.git", @@ -1026,7 +1026,7 @@ "description": "A generic function and convention to trigger deprecation notices", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/deprecation-contracts/tree/v2.5.1" + "source": "https://github.com/symfony/deprecation-contracts/tree/v2.5.2" }, "funding": [ { @@ -1727,16 +1727,16 @@ }, { "name": "symfony/service-contracts", - "version": "v2.5.1", + "version": "v2.5.2", "source": { "type": "git", "url": "https://github.com/symfony/service-contracts.git", - "reference": "24d9dc654b83e91aa59f9d167b131bc3b5bea24c" + "reference": "4b426aac47d6427cc1a1d0f7e2ac724627f5966c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/24d9dc654b83e91aa59f9d167b131bc3b5bea24c", - "reference": "24d9dc654b83e91aa59f9d167b131bc3b5bea24c", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/4b426aac47d6427cc1a1d0f7e2ac724627f5966c", + "reference": "4b426aac47d6427cc1a1d0f7e2ac724627f5966c", "shasum": "" }, "require": { @@ -1790,7 +1790,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/service-contracts/tree/v2.5.1" + "source": "https://github.com/symfony/service-contracts/tree/v2.5.2" }, "funding": [ { @@ -1806,20 +1806,20 @@ "type": "tidelift" } ], - "time": "2022-03-13T20:07:29+00:00" + "time": "2022-05-30T19:17:29+00:00" }, { "name": "symfony/string", - "version": "v5.4.9", + "version": "v5.4.10", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "985e6a9703ef5ce32ba617c9c7d97873bb7b2a99" + "reference": "4432bc7df82a554b3e413a8570ce2fea90e94097" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/985e6a9703ef5ce32ba617c9c7d97873bb7b2a99", - "reference": "985e6a9703ef5ce32ba617c9c7d97873bb7b2a99", + "url": "https://api.github.com/repos/symfony/string/zipball/4432bc7df82a554b3e413a8570ce2fea90e94097", + "reference": "4432bc7df82a554b3e413a8570ce2fea90e94097", "shasum": "" }, "require": { @@ -1876,7 +1876,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v5.4.9" + "source": "https://github.com/symfony/string/tree/v5.4.10" }, "funding": [ { @@ -1892,22 +1892,22 @@ "type": "tidelift" } ], - "time": "2022-04-19T10:40:37+00:00" + "time": "2022-06-26T15:57:47+00:00" } ], "packages-dev": [ { "name": "phpstan/phpstan", - "version": "1.7.15", + "version": "1.8.0", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "cd0202ea1b1fc6d1bbe156c6e2e18a03e0ff160a" + "reference": "b7648d4ee9321665acaf112e49da9fd93df8fbd5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/cd0202ea1b1fc6d1bbe156c6e2e18a03e0ff160a", - "reference": "cd0202ea1b1fc6d1bbe156c6e2e18a03e0ff160a", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/b7648d4ee9321665acaf112e49da9fd93df8fbd5", + "reference": "b7648d4ee9321665acaf112e49da9fd93df8fbd5", "shasum": "" }, "require": { @@ -1933,7 +1933,7 @@ "description": "PHPStan - PHP Static Analysis Tool", "support": { "issues": "https://github.com/phpstan/phpstan/issues", - "source": "https://github.com/phpstan/phpstan/tree/1.7.15" + "source": "https://github.com/phpstan/phpstan/tree/1.8.0" }, "funding": [ { @@ -1953,7 +1953,7 @@ "type": "tidelift" } ], - "time": "2022-06-20T08:29:01+00:00" + "time": "2022-06-29T08:53:31+00:00" }, { "name": "phpstan/phpstan-deprecation-rules", @@ -2059,21 +2059,21 @@ }, { "name": "phpstan/phpstan-strict-rules", - "version": "1.2.3", + "version": "1.3.0", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan-strict-rules.git", - "reference": "0c82c96f2a55d8b91bbc7ee6512c94f68a206b43" + "reference": "543675a9be82d4befb9ca0bd8cdc9d211665037f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan-strict-rules/zipball/0c82c96f2a55d8b91bbc7ee6512c94f68a206b43", - "reference": "0c82c96f2a55d8b91bbc7ee6512c94f68a206b43", + "url": "https://api.github.com/repos/phpstan/phpstan-strict-rules/zipball/543675a9be82d4befb9ca0bd8cdc9d211665037f", + "reference": "543675a9be82d4befb9ca0bd8cdc9d211665037f", "shasum": "" }, "require": { "php": "^7.2 || ^8.0", - "phpstan/phpstan": "^1.6.3" + "phpstan/phpstan": "^1.7.15" }, "require-dev": { "nikic/php-parser": "^4.13.0", @@ -2101,9 +2101,9 @@ "description": "Extra strict and opinionated rules for PHPStan", "support": { "issues": "https://github.com/phpstan/phpstan-strict-rules/issues", - "source": "https://github.com/phpstan/phpstan-strict-rules/tree/1.2.3" + "source": "https://github.com/phpstan/phpstan-strict-rules/tree/1.3.0" }, - "time": "2022-05-04T15:20:40+00:00" + "time": "2022-06-24T06:47:20+00:00" }, { "name": "phpstan/phpstan-symfony", @@ -2178,16 +2178,16 @@ }, { "name": "symfony/phpunit-bridge", - "version": "v6.1.0", + "version": "v6.1.2", "source": { "type": "git", "url": "https://github.com/symfony/phpunit-bridge.git", - "reference": "092ccc3b364925cd8ed6046bc31dcf3a022bd5a4" + "reference": "899fdec151add3dc339cf394a15100a1acc177ad" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/phpunit-bridge/zipball/092ccc3b364925cd8ed6046bc31dcf3a022bd5a4", - "reference": "092ccc3b364925cd8ed6046bc31dcf3a022bd5a4", + "url": "https://api.github.com/repos/symfony/phpunit-bridge/zipball/899fdec151add3dc339cf394a15100a1acc177ad", + "reference": "899fdec151add3dc339cf394a15100a1acc177ad", "shasum": "" }, "require": { @@ -2241,7 +2241,7 @@ "description": "Provides utilities for PHPUnit, especially user deprecation notices management", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/phpunit-bridge/tree/v6.1.0" + "source": "https://github.com/symfony/phpunit-bridge/tree/v6.1.2" }, "funding": [ { @@ -2257,7 +2257,7 @@ "type": "tidelift" } ], - "time": "2022-04-12T16:22:53+00:00" + "time": "2022-06-20T12:01:07+00:00" } ], "aliases": [], diff --git a/phpstan/baseline.neon b/phpstan/baseline.neon index 335235af8..1dd2336c1 100644 --- a/phpstan/baseline.neon +++ b/phpstan/baseline.neon @@ -595,16 +595,6 @@ parameters: count: 7 path: ../src/Composer/Command/InitCommand.php - - - message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" - count: 2 - path: ../src/Composer/Command/LicensesCommand.php - - - - message: "#^Foreach overwrites \\$package with its value variable\\.$#" - count: 1 - path: ../src/Composer/Command/LicensesCommand.php - - message: "#^Short ternary operator is not allowed\\. Use null coalesce operator if applicable or consider using long ternary\\.$#" count: 2 @@ -1645,11 +1635,6 @@ parameters: count: 1 path: ../src/Composer/DependencyResolver/RuleSetIterator.php - - - message: "#^Only booleans are allowed in an if condition, array\\ given\\.$#" - count: 1 - path: ../src/Composer/DependencyResolver/RuleWatchGraph.php - - message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#" count: 2 @@ -1675,11 +1660,6 @@ parameters: count: 1 path: ../src/Composer/DependencyResolver/Solver.php - - - message: "#^Only booleans are allowed in a negated boolean, Composer\\\\DependencyResolver\\\\Rule\\|null given\\.$#" - count: 1 - path: ../src/Composer/DependencyResolver/Solver.php - - message: "#^Only booleans are allowed in a negated boolean, array\\ given\\.$#" count: 1 @@ -1726,7 +1706,7 @@ parameters: path: ../src/Composer/DependencyResolver/Solver.php - - message: "#^Parameter \\#1 \\$literals of class Composer\\\\DependencyResolver\\\\GenericRule constructor expects array\\, array\\ given\\.$#" + message: "#^Parameter \\#1 \\$literals of class Composer\\\\DependencyResolver\\\\GenericRule constructor expects array\\, array\\ given\\.$#" count: 1 path: ../src/Composer/DependencyResolver/Solver.php @@ -2830,11 +2810,6 @@ parameters: count: 1 path: ../src/Composer/Json/JsonFile.php - - - message: "#^Only booleans are allowed in a negated boolean, string\\|false given\\.$#" - count: 1 - path: ../src/Composer/Json/JsonFile.php - - message: "#^Only booleans are allowed in a ternary operator condition, int given\\.$#" count: 1 diff --git a/src/Composer/Command/BaseCommand.php b/src/Composer/Command/BaseCommand.php index 354b95be8..75048a672 100644 --- a/src/Composer/Command/BaseCommand.php +++ b/src/Composer/Command/BaseCommand.php @@ -244,13 +244,13 @@ abstract class BaseCommand extends Command } if (true === $input->hasOption('no-dev')) { - if (!$input->getOption('no-dev') && true == Platform::getEnv('COMPOSER_NO_DEV')) { + if (!$input->getOption('no-dev') && (bool) Platform::getEnv('COMPOSER_NO_DEV')) { $input->setOption('no-dev', true); } } if (true === $input->hasOption('ignore-platform-reqs')) { - if (!$input->getOption('ignore-platform-reqs') && true == Platform::getEnv('COMPOSER_IGNORE_PLATFORM_REQS')) { + if (!$input->getOption('ignore-platform-reqs') && (bool) Platform::getEnv('COMPOSER_IGNORE_PLATFORM_REQS')) { $input->setOption('ignore-platform-reqs', true); $io->writeError('COMPOSER_IGNORE_PLATFORM_REQS is set. You may experience unexpected errors.'); diff --git a/src/Composer/Command/BaseDependencyCommand.php b/src/Composer/Command/BaseDependencyCommand.php index 992d6473a..9788ffa23 100644 --- a/src/Composer/Command/BaseDependencyCommand.php +++ b/src/Composer/Command/BaseDependencyCommand.php @@ -234,7 +234,7 @@ abstract class BaseDependencyCommand extends BaseCommand $color = $this->colors[$level % count($this->colors)]; $prevColor = $this->colors[($level - 1) % count($this->colors)]; - $isLast = (++$idx == $count); + $isLast = (++$idx === $count); $versionText = $package->getPrettyVersion() === RootPackage::DEFAULT_PRETTY_VERSION ? '' : $package->getPrettyVersion(); $packageText = rtrim(sprintf('<%s>%s %s', $color, $package->getPrettyName(), $versionText)); $linkText = sprintf('%s <%s>%s %s', $link->getDescription(), $prevColor, $link->getTarget(), $link->getPrettyConstraint()); diff --git a/src/Composer/Command/ConfigCommand.php b/src/Composer/Command/ConfigCommand.php index 0215dba32..e79c1541b 100644 --- a/src/Composer/Command/ConfigCommand.php +++ b/src/Composer/Command/ConfigCommand.php @@ -921,7 +921,7 @@ EOT $id = Preg::replace('{-+}', '-', $id); $link = 'https://getcomposer.org/doc/06-config.md#' . $id; } - if (is_string($rawVal) && $rawVal != $value) { + if (is_string($rawVal) && $rawVal !== $value) { $io->write('[' . $k . $key . '] ' . $rawVal . ' (' . $value . ')' . $source, true, IOInterface::QUIET); } else { $io->write('[' . $k . $key . '] ' . $value . '' . $source, true, IOInterface::QUIET); diff --git a/src/Composer/Command/UpdateCommand.php b/src/Composer/Command/UpdateCommand.php index c4659693e..51b32ede8 100644 --- a/src/Composer/Command/UpdateCommand.php +++ b/src/Composer/Command/UpdateCommand.php @@ -182,7 +182,7 @@ EOT $filteredPackages = array_filter($packages, static function ($package): bool { return !in_array($package, array('lock', 'nothing', 'mirrors'), true); }); - $updateMirrors = $input->getOption('lock') || count($filteredPackages) != count($packages); + $updateMirrors = $input->getOption('lock') || count($filteredPackages) !== count($packages); $packages = $filteredPackages; if ($updateMirrors && !empty($packages)) { diff --git a/src/Composer/Compiler.php b/src/Composer/Compiler.php index b184e2519..528dfa97c 100644 --- a/src/Composer/Compiler.php +++ b/src/Composer/Compiler.php @@ -51,13 +51,13 @@ class Compiler } $process = new Process(array('git', 'log', '--pretty=%H', '-n1', 'HEAD'), __DIR__); - if ($process->run() != 0) { + if ($process->run() !== 0) { throw new \RuntimeException('Can\'t run git log. You must ensure to run compile from composer git repository clone and that git binary is available.'); } $this->version = trim($process->getOutput()); $process = new Process(array('git', 'log', '-n1', '--pretty=%ci', 'HEAD'), __DIR__); - if ($process->run() != 0) { + if ($process->run() !== 0) { throw new \RuntimeException('Can\'t run git log. You must ensure to run compile from composer git repository clone and that git binary is available.'); } @@ -65,7 +65,7 @@ class Compiler $this->versionDate->setTimezone(new \DateTimeZone('UTC')); $process = new Process(array('git', 'describe', '--tags', '--exact-match', 'HEAD'), __DIR__); - if ($process->run() == 0) { + if ($process->run() === 0) { $this->version = trim($process->getOutput()); } else { // get branch-alias defined in composer.json for dev-main (if any) diff --git a/src/Composer/Config.php b/src/Composer/Config.php index 5a0ded2a1..a8b7bb6f9 100644 --- a/src/Composer/Config.php +++ b/src/Composer/Config.php @@ -311,7 +311,7 @@ class Config return $val; } - return (($flags & self::RELATIVE_PATHS) == self::RELATIVE_PATHS) ? $val : $this->realpath($val); + return (($flags & self::RELATIVE_PATHS) === self::RELATIVE_PATHS) ? $val : $this->realpath($val); // booleans with env var support case 'cache-read-only': diff --git a/src/Composer/Console/Application.php b/src/Composer/Console/Application.php index d1b304535..82cc0b2a0 100644 --- a/src/Composer/Console/Application.php +++ b/src/Composer/Console/Application.php @@ -298,7 +298,7 @@ class Application extends BaseApplication // Check system temp folder for usability as it can cause weird runtime issues otherwise Silencer::call(static function () use ($io): void { $tempfile = sys_get_temp_dir() . '/temp-' . md5(microtime()); - if (!(file_put_contents($tempfile, __FILE__) && (file_get_contents($tempfile) == __FILE__) && unlink($tempfile) && !file_exists($tempfile))) { + if (!(file_put_contents($tempfile, __FILE__) && (file_get_contents($tempfile) === __FILE__) && unlink($tempfile) && !file_exists($tempfile))) { $io->writeError(sprintf('PHP temp directory (%s) does not exist or is not writable to Composer. Set sys_temp_dir in your php.ini', sys_get_temp_dir())); } }); diff --git a/src/Composer/DependencyResolver/Decisions.php b/src/Composer/DependencyResolver/Decisions.php index fce11c269..543ab2efa 100644 --- a/src/Composer/DependencyResolver/Decisions.php +++ b/src/Composer/DependencyResolver/Decisions.php @@ -256,12 +256,12 @@ class Decisions implements \Iterator, \Countable { $packageId = abs($literal); - $previousDecision = $this->decisionMap[$packageId] ?? null; - if ($previousDecision != 0) { + $previousDecision = $this->decisionMap[$packageId] ?? 0; + if ($previousDecision !== 0) { $literalString = $this->pool->literalToPrettyString($literal, array()); $package = $this->pool->literalToPackage($literal); throw new SolverBugException( - "Trying to decide $literalString on level $level, even though $package was previously decided as ".(int) $previousDecision."." + "Trying to decide $literalString on level $level, even though $package was previously decided as ".$previousDecision."." ); } diff --git a/src/Composer/DependencyResolver/GenericRule.php b/src/Composer/DependencyResolver/GenericRule.php index b18414666..d119d944b 100644 --- a/src/Composer/DependencyResolver/GenericRule.php +++ b/src/Composer/DependencyResolver/GenericRule.php @@ -17,11 +17,11 @@ namespace Composer\DependencyResolver; */ class GenericRule extends Rule { - /** @var int[] */ + /** @var list */ protected $literals; /** - * @param int[] $literals + * @param list $literals */ public function __construct(array $literals, $reason, $reasonData) { @@ -34,7 +34,7 @@ class GenericRule extends Rule } /** - * @return int[] + * @return list */ public function getLiterals(): array { @@ -82,7 +82,7 @@ class GenericRule extends Rule $result = $this->isDisabled() ? 'disabled(' : '('; foreach ($this->literals as $i => $literal) { - if ($i != 0) { + if ($i !== 0) { $result .= '|'; } $result .= $literal; diff --git a/src/Composer/DependencyResolver/LockTransaction.php b/src/Composer/DependencyResolver/LockTransaction.php index b05afa7c1..8e407b1fe 100644 --- a/src/Composer/DependencyResolver/LockTransaction.php +++ b/src/Composer/DependencyResolver/LockTransaction.php @@ -92,7 +92,7 @@ class LockTransaction extends Transaction foreach ($packages as $package) { foreach ($this->resultPackages['dev'] as $i => $resultPackage) { // TODO this comparison is probably insufficient, aliases, what about modified versions? I guess they aren't possible? - if ($package->getName() == $resultPackage->getName()) { + if ($package->getName() === $resultPackage->getName()) { $this->resultPackages['non-dev'][] = $resultPackage; unset($this->resultPackages['dev'][$i]); } @@ -115,7 +115,7 @@ class LockTransaction extends Transaction // we do not reset references if the currently present package didn't have any, or if the type of VCS has changed if ($updateMirrors && !isset($this->presentMap[spl_object_hash($package)])) { foreach ($this->presentMap as $presentPackage) { - if ($package->getName() == $presentPackage->getName() && $package->getVersion() == $presentPackage->getVersion()) { + if ($package->getName() === $presentPackage->getName() && $package->getVersion() === $presentPackage->getVersion()) { if ($presentPackage->getSourceReference() && $presentPackage->getSourceType() === $package->getSourceType()) { $package->setSourceDistReferences($presentPackage->getSourceReference()); } diff --git a/src/Composer/DependencyResolver/MultiConflictRule.php b/src/Composer/DependencyResolver/MultiConflictRule.php index 63fe1e09e..d065a2a30 100644 --- a/src/Composer/DependencyResolver/MultiConflictRule.php +++ b/src/Composer/DependencyResolver/MultiConflictRule.php @@ -19,11 +19,11 @@ namespace Composer\DependencyResolver; */ class MultiConflictRule extends Rule { - /** @var int[] */ + /** @var list */ protected $literals; /** - * @param int[] $literals + * @param list $literals */ public function __construct(array $literals, $reason, $reasonData) { @@ -40,7 +40,7 @@ class MultiConflictRule extends Rule } /** - * @return int[] + * @return list */ public function getLiterals(): array { @@ -102,7 +102,7 @@ class MultiConflictRule extends Rule $result = $this->isDisabled() ? 'disabled(multi(' : '(multi('; foreach ($this->literals as $i => $literal) { - if ($i != 0) { + if ($i !== 0) { $result .= '|'; } $result .= $literal; diff --git a/src/Composer/DependencyResolver/Rule.php b/src/Composer/DependencyResolver/Rule.php index 7398d2046..cb5a7f1c6 100644 --- a/src/Composer/DependencyResolver/Rule.php +++ b/src/Composer/DependencyResolver/Rule.php @@ -69,7 +69,7 @@ abstract class Rule } /** - * @return int[] + * @return list */ abstract public function getLiterals(): array; @@ -380,13 +380,13 @@ abstract class Rule $reason = null; if (!isset($packageNames[$replacedName])) { - $reason = 'They '.(count($literals) == 2 ? 'both' : 'all').' replace '.$replacedName.' and thus cannot coexist.'; + $reason = 'They '.(count($literals) === 2 ? 'both' : 'all').' replace '.$replacedName.' and thus cannot coexist.'; } else { $replacerNames = $packageNames; unset($replacerNames[$replacedName]); $replacerNames = array_keys($replacerNames); - if (count($replacerNames) == 1) { + if (count($replacerNames) === 1) { $reason = $replacerNames[0] . ' replaces '; } else { $reason = '['.implode(', ', $replacerNames).'] replace '; @@ -469,7 +469,7 @@ abstract class Rule default: $ruleText = ''; foreach ($literals as $i => $literal) { - if ($i != 0) { + if ($i !== 0) { $ruleText .= '|'; } $ruleText .= $pool->literalToPrettyString($literal, $installedMap); diff --git a/src/Composer/DependencyResolver/Rule2Literals.php b/src/Composer/DependencyResolver/Rule2Literals.php index bfac6dbfe..94a9a9791 100644 --- a/src/Composer/DependencyResolver/Rule2Literals.php +++ b/src/Composer/DependencyResolver/Rule2Literals.php @@ -44,7 +44,9 @@ class Rule2Literals extends Rule } } - /** @return int[] */ + /** + * @return list + */ public function getLiterals(): array { return array($this->literal1, $this->literal2); @@ -82,7 +84,7 @@ class Rule2Literals extends Rule } $literals = $rule->getLiterals(); - if (2 != \count($literals)) { + if (2 !== \count($literals)) { return false; } diff --git a/src/Composer/DependencyResolver/RuleSetGenerator.php b/src/Composer/DependencyResolver/RuleSetGenerator.php index c91141d54..59eefdf60 100644 --- a/src/Composer/DependencyResolver/RuleSetGenerator.php +++ b/src/Composer/DependencyResolver/RuleSetGenerator.php @@ -134,7 +134,7 @@ class RuleSetGenerator $literals[] = -$package->id; } - if (\count($literals) == 2) { + if (\count($literals) === 2) { return new Rule2Literals($literals[0], $literals[1], $reason, $reasonData); } @@ -262,7 +262,7 @@ class RuleSetGenerator protected function addRulesForRequest(Request $request, PlatformRequirementFilterInterface $platformRequirementFilter): void { foreach ($request->getFixedPackages() as $package) { - if ($package->id == -1) { + if ($package->id === -1) { // fixed package was not added to the pool as it did not pass the stability requirements, this is fine if ($this->pool->isUnacceptableFixedOrLockedPackage($package)) { continue; diff --git a/src/Composer/DependencyResolver/RuleWatchGraph.php b/src/Composer/DependencyResolver/RuleWatchGraph.php index 5a30cdc06..375563863 100644 --- a/src/Composer/DependencyResolver/RuleWatchGraph.php +++ b/src/Composer/DependencyResolver/RuleWatchGraph.php @@ -116,7 +116,7 @@ class RuleWatchGraph !$decisions->conflict($ruleLiteral); }); - if ($alternativeLiterals) { + if (\count($alternativeLiterals) > 0) { reset($alternativeLiterals); $this->moveWatch($literal, current($alternativeLiterals), $node); continue; diff --git a/src/Composer/DependencyResolver/RuleWatchNode.php b/src/Composer/DependencyResolver/RuleWatchNode.php index 54e4283c0..f102086e6 100644 --- a/src/Composer/DependencyResolver/RuleWatchNode.php +++ b/src/Composer/DependencyResolver/RuleWatchNode.php @@ -93,7 +93,7 @@ class RuleWatchNode */ public function getOtherWatch(int $literal): int { - if ($this->watch1 == $literal) { + if ($this->watch1 === $literal) { return $this->watch2; } @@ -109,7 +109,7 @@ class RuleWatchNode */ public function moveWatch(int $from, int $to): void { - if ($this->watch1 == $from) { + if ($this->watch1 === $from) { $this->watch1 = $to; } else { $this->watch2 = $to; diff --git a/src/Composer/DependencyResolver/Solver.php b/src/Composer/DependencyResolver/Solver.php index 2c416a95e..05d2a39df 100644 --- a/src/Composer/DependencyResolver/Solver.php +++ b/src/Composer/DependencyResolver/Solver.php @@ -311,11 +311,11 @@ class Solver while (true) { $rule = $this->propagate($level); - if (!$rule) { + if (null === $rule) { break; } - if ($level == 1) { + if ($level === 1) { return $this->analyzeUnsolvable($rule); } @@ -523,7 +523,7 @@ class Solver $why = spl_object_hash($conflictRule); $ruleSeen[$why] = true; - if ($conflictRule->getType() == RuleSet::TYPE_LEARNED) { + if ($conflictRule->getType() === RuleSet::TYPE_LEARNED) { $learnedWhy = $this->learnedWhy[$why]; $problemRules = $this->learnedPool[$learnedWhy]; @@ -536,7 +536,7 @@ class Solver return; } - if ($conflictRule->getType() == RuleSet::TYPE_PACKAGE) { + if ($conflictRule->getType() === RuleSet::TYPE_PACKAGE) { // package rules cannot be part of a problem return; } @@ -723,7 +723,7 @@ class Solver $this->io->writeError('Looking at all rules.', true, IOInterface::DEBUG); for ($i = 0, $n = 0; $n < $rulesCount; $i++, $n++) { - if ($i == $rulesCount) { + if ($i === $rulesCount) { if (1 === $pass) { $this->io->writeError("Something's changed, looking at all rules again (pass #$pass)", false, IOInterface::DEBUG); } else { @@ -814,7 +814,7 @@ class Solver $level = $this->setPropagateLearn($level, $lastLiteral, $why); - if ($level == 0) { + if ($level === 0) { return; } diff --git a/src/Composer/DependencyResolver/Transaction.php b/src/Composer/DependencyResolver/Transaction.php index 5df550591..2c7d06fa6 100644 --- a/src/Composer/DependencyResolver/Transaction.php +++ b/src/Composer/DependencyResolver/Transaction.php @@ -73,8 +73,8 @@ class Transaction { $packageSort = static function (PackageInterface $a, PackageInterface $b): int { // sort alias packages by the same name behind their non alias version - if ($a->getName() == $b->getName()) { - if ($a instanceof AliasPackage != $b instanceof AliasPackage) { + if ($a->getName() === $b->getName()) { + if ($a instanceof AliasPackage !== $b instanceof AliasPackage) { return $a instanceof AliasPackage ? -1 : 1; } // if names are the same, compare version, e.g. to sort aliases reliably, actual order does not matter @@ -162,7 +162,7 @@ class Transaction // do we need to update? // TODO different for lock? - if ($package->getVersion() != $presentPackageMap[$package->getName()]->getVersion() || + if ($package->getVersion() !== $presentPackageMap[$package->getName()]->getVersion() || $package->getDistReference() !== $presentPackageMap[$package->getName()]->getDistReference() || $package->getSourceReference() !== $presentPackageMap[$package->getName()]->getSourceReference() ) { diff --git a/src/Composer/Installer.php b/src/Composer/Installer.php index c6bc21c0f..59e4c502c 100644 --- a/src/Composer/Installer.php +++ b/src/Composer/Installer.php @@ -530,8 +530,8 @@ class Installer // when mirrors/metadata from a package gets updated we do not want to list it as an // update in the output as it is only an internal lock file metadata update if ($this->updateMirrors - && $operation->getInitialPackage()->getName() == $operation->getTargetPackage()->getName() - && $operation->getInitialPackage()->getVersion() == $operation->getTargetPackage()->getVersion() + && $operation->getInitialPackage()->getName() === $operation->getTargetPackage()->getName() + && $operation->getInitialPackage()->getVersion() === $operation->getTargetPackage()->getVersion() ) { continue; } diff --git a/src/Composer/Json/JsonFile.php b/src/Composer/Json/JsonFile.php index 22f1e8f67..805ca57ee 100644 --- a/src/Composer/Json/JsonFile.php +++ b/src/Composer/Json/JsonFile.php @@ -177,7 +177,7 @@ class JsonFile private function filePutContentsIfModified(string $path, string $content) { $currentContent = @file_get_contents($path); - if (!$currentContent || ($currentContent != $content)) { + if (false === $currentContent || $currentContent !== $content) { return file_put_contents($path, $content); } diff --git a/src/Composer/Package/Archiver/GitExcludeFilter.php b/src/Composer/Package/Archiver/GitExcludeFilter.php index 2d41e9c08..12b4c5a65 100644 --- a/src/Composer/Package/Archiver/GitExcludeFilter.php +++ b/src/Composer/Package/Archiver/GitExcludeFilter.php @@ -54,11 +54,11 @@ class GitExcludeFilter extends BaseExcludeFilter { $parts = Preg::split('#\s+#', $line); - if (count($parts) == 2 && $parts[1] === 'export-ignore') { + if (count($parts) === 2 && $parts[1] === 'export-ignore') { return $this->generatePattern($parts[0]); } - if (count($parts) == 2 && $parts[1] === '-export-ignore') { + if (count($parts) === 2 && $parts[1] === '-export-ignore') { return $this->generatePattern('!'.$parts[0]); } diff --git a/src/Composer/Package/Version/VersionSelector.php b/src/Composer/Package/Version/VersionSelector.php index b2a2f56ac..241251779 100644 --- a/src/Composer/Package/Version/VersionSelector.php +++ b/src/Composer/Package/Version/VersionSelector.php @@ -237,7 +237,7 @@ class VersionSelector $semanticVersionParts = explode('.', $version); // check to see if we have a semver-looking version - if (count($semanticVersionParts) == 4 && Preg::isMatch('{^0\D?}', $semanticVersionParts[3])) { + if (count($semanticVersionParts) === 4 && Preg::isMatch('{^0\D?}', $semanticVersionParts[3])) { // remove the last parts (i.e. the patch version number and any extra) if ($semanticVersionParts[0] === '0') { unset($semanticVersionParts[3]); @@ -250,7 +250,7 @@ class VersionSelector } // append stability flag if not default - if ($stability != 'stable') { + if ($stability !== 'stable') { $version .= '@'.$stability; } diff --git a/src/Composer/Repository/FilesystemRepository.php b/src/Composer/Repository/FilesystemRepository.php index 94e8ef999..8a87970bb 100644 --- a/src/Composer/Repository/FilesystemRepository.php +++ b/src/Composer/Repository/FilesystemRepository.php @@ -202,7 +202,7 @@ class FilesystemRepository extends WritableArrayRepository } } - $lines .= str_repeat(' ', $level - 1) . ')' . ($level - 1 == 0 ? '' : ",\n"); + $lines .= str_repeat(' ', $level - 1) . ')' . ($level - 1 === 0 ? '' : ",\n"); return $lines; } diff --git a/src/Composer/Util/AuthHelper.php b/src/Composer/Util/AuthHelper.php index d36bd6111..5e0fa4874 100644 --- a/src/Composer/Util/AuthHelper.php +++ b/src/Composer/Util/AuthHelper.php @@ -302,6 +302,6 @@ class AuthHelper // {@link https://blog.bitbucket.org/2009/04/12/new-feature-downloads/} $pathParts = explode('/', $path); - return count($pathParts) >= 4 && $pathParts[3] == 'downloads'; + return count($pathParts) >= 4 && $pathParts[3] === 'downloads'; } } diff --git a/src/Composer/Util/ConfigValidator.php b/src/Composer/Util/ConfigValidator.php index b3a3346db..82cd39171 100644 --- a/src/Composer/Util/ConfigValidator.php +++ b/src/Composer/Util/ConfigValidator.php @@ -142,7 +142,7 @@ class ConfigValidator ); } - if (!empty($manifest['type']) && $manifest['type'] == 'composer-installer') { + if (!empty($manifest['type']) && $manifest['type'] === 'composer-installer') { $warnings[] = "The package type 'composer-installer' is deprecated. Please distribute your custom installers as plugins from now on. See https://getcomposer.org/doc/articles/plugins.md for plugin documentation."; } diff --git a/src/Composer/Util/Http/CurlDownloader.php b/src/Composer/Util/Http/CurlDownloader.php index ffb04e6f8..98af5c1a1 100644 --- a/src/Composer/Util/Http/CurlDownloader.php +++ b/src/Composer/Util/Http/CurlDownloader.php @@ -369,7 +369,7 @@ class CurlDownloader continue; } - if ($errno === 28 /* CURLE_OPERATION_TIMEDOUT */ && PHP_VERSION_ID >= 70300 && $progress['namelookup_time'] == 0 && !$timeoutWarning) { + if ($errno === 28 /* CURLE_OPERATION_TIMEDOUT */ && PHP_VERSION_ID >= 70300 && $progress['namelookup_time'] === 0.0 && !$timeoutWarning) { $timeoutWarning = true; $this->io->writeError('A connection timeout was encountered. If you intend to run Composer without connecting to the internet, run the command again prefixed with COMPOSER_DISABLE_NETWORK=1 to make Composer run in offline mode.'); } @@ -669,7 +669,7 @@ class CurlDownloader */ private function checkCurlResult(int $code): void { - if ($code != CURLM_OK && $code != CURLM_CALL_MULTI_PERFORM) { + if ($code !== CURLM_OK && $code !== CURLM_CALL_MULTI_PERFORM) { throw new \RuntimeException( isset($this->multiErrors[$code]) ? "cURL error: {$code} ({$this->multiErrors[$code][0]}): cURL message: {$this->multiErrors[$code][1]}" diff --git a/src/Composer/Util/Perforce.php b/src/Composer/Util/Perforce.php index 65d2a0318..8355d7f6f 100644 --- a/src/Composer/Util/Perforce.php +++ b/src/Composer/Util/Perforce.php @@ -339,7 +339,7 @@ class Perforce $resArray = explode(PHP_EOL, $result); foreach ($resArray as $line) { $fields = explode('=', $line); - if (strcmp($name, $fields[0]) == 0) { + if (strcmp($name, $fields[0]) === 0) { $index = strpos($fields[1], ' '); if ($index === false) { $value = $fields[1]; diff --git a/src/Composer/Util/Platform.php b/src/Composer/Util/Platform.php index 9c48e670a..ad9ffdc16 100644 --- a/src/Composer/Util/Platform.php +++ b/src/Composer/Util/Platform.php @@ -110,7 +110,7 @@ class Platform return Preg::replaceCallback('#^(\$|(?P%))(?P\w++)(?(percent)%)(?P.*)#', static function ($matches): string { // Treat HOME as an alias for USERPROFILE on Windows for legacy reasons - if (Platform::isWindows() && $matches['var'] == 'HOME') { + if (Platform::isWindows() && $matches['var'] === 'HOME') { return (Platform::getEnv('HOME') ?: Platform::getEnv('USERPROFILE')) . $matches['path']; } diff --git a/src/Composer/Util/Zip.php b/src/Composer/Util/Zip.php index 20c33771b..96b705c8f 100644 --- a/src/Composer/Util/Zip.php +++ b/src/Composer/Util/Zip.php @@ -35,7 +35,7 @@ class Zip return null; } - if (0 == $zip->numFiles) { + if (0 === $zip->numFiles) { $zip->close(); return null; diff --git a/tests/Composer/Test/InstallerTest.php b/tests/Composer/Test/InstallerTest.php index d714e618b..33d97a199 100644 --- a/tests/Composer/Test/InstallerTest.php +++ b/tests/Composer/Test/InstallerTest.php @@ -420,7 +420,7 @@ class InstallerTest extends TestCase $filteredPackages = array_filter($packages, function ($package): bool { return !in_array($package, array('lock', 'nothing', 'mirrors'), true); }); - $updateMirrors = $input->getOption('lock') || count($filteredPackages) != count($packages); + $updateMirrors = $input->getOption('lock') || count($filteredPackages) !== count($packages); $packages = $filteredPackages; $updateAllowTransitiveDependencies = Request::UPDATE_ONLY_LISTED;