1
0
Fork 0

Update phpstan to latest, update baseline (1909, 103)

pull/10908/head
Jordi Boggiano 2022-06-30 17:07:18 +02:00
parent 51db9e823c
commit 1812862d5e
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
32 changed files with 101 additions and 124 deletions

78
composer.lock generated
View File

@ -880,16 +880,16 @@
}, },
{ {
"name": "symfony/console", "name": "symfony/console",
"version": "v5.4.9", "version": "v5.4.10",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/console.git", "url": "https://github.com/symfony/console.git",
"reference": "829d5d1bf60b2efeb0887b7436873becc71a45eb" "reference": "4d671ab4ddac94ee439ea73649c69d9d200b5000"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/console/zipball/829d5d1bf60b2efeb0887b7436873becc71a45eb", "url": "https://api.github.com/repos/symfony/console/zipball/4d671ab4ddac94ee439ea73649c69d9d200b5000",
"reference": "829d5d1bf60b2efeb0887b7436873becc71a45eb", "reference": "4d671ab4ddac94ee439ea73649c69d9d200b5000",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -959,7 +959,7 @@
"terminal" "terminal"
], ],
"support": { "support": {
"source": "https://github.com/symfony/console/tree/v5.4.9" "source": "https://github.com/symfony/console/tree/v5.4.10"
}, },
"funding": [ "funding": [
{ {
@ -975,11 +975,11 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2022-05-18T06:17:34+00:00" "time": "2022-06-26T13:00:04+00:00"
}, },
{ {
"name": "symfony/deprecation-contracts", "name": "symfony/deprecation-contracts",
"version": "v2.5.1", "version": "v2.5.2",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/deprecation-contracts.git", "url": "https://github.com/symfony/deprecation-contracts.git",
@ -1026,7 +1026,7 @@
"description": "A generic function and convention to trigger deprecation notices", "description": "A generic function and convention to trigger deprecation notices",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"support": { "support": {
"source": "https://github.com/symfony/deprecation-contracts/tree/v2.5.1" "source": "https://github.com/symfony/deprecation-contracts/tree/v2.5.2"
}, },
"funding": [ "funding": [
{ {
@ -1727,16 +1727,16 @@
}, },
{ {
"name": "symfony/service-contracts", "name": "symfony/service-contracts",
"version": "v2.5.1", "version": "v2.5.2",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/service-contracts.git", "url": "https://github.com/symfony/service-contracts.git",
"reference": "24d9dc654b83e91aa59f9d167b131bc3b5bea24c" "reference": "4b426aac47d6427cc1a1d0f7e2ac724627f5966c"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/service-contracts/zipball/24d9dc654b83e91aa59f9d167b131bc3b5bea24c", "url": "https://api.github.com/repos/symfony/service-contracts/zipball/4b426aac47d6427cc1a1d0f7e2ac724627f5966c",
"reference": "24d9dc654b83e91aa59f9d167b131bc3b5bea24c", "reference": "4b426aac47d6427cc1a1d0f7e2ac724627f5966c",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1790,7 +1790,7 @@
"standards" "standards"
], ],
"support": { "support": {
"source": "https://github.com/symfony/service-contracts/tree/v2.5.1" "source": "https://github.com/symfony/service-contracts/tree/v2.5.2"
}, },
"funding": [ "funding": [
{ {
@ -1806,20 +1806,20 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2022-03-13T20:07:29+00:00" "time": "2022-05-30T19:17:29+00:00"
}, },
{ {
"name": "symfony/string", "name": "symfony/string",
"version": "v5.4.9", "version": "v5.4.10",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/string.git", "url": "https://github.com/symfony/string.git",
"reference": "985e6a9703ef5ce32ba617c9c7d97873bb7b2a99" "reference": "4432bc7df82a554b3e413a8570ce2fea90e94097"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/string/zipball/985e6a9703ef5ce32ba617c9c7d97873bb7b2a99", "url": "https://api.github.com/repos/symfony/string/zipball/4432bc7df82a554b3e413a8570ce2fea90e94097",
"reference": "985e6a9703ef5ce32ba617c9c7d97873bb7b2a99", "reference": "4432bc7df82a554b3e413a8570ce2fea90e94097",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1876,7 +1876,7 @@
"utf8" "utf8"
], ],
"support": { "support": {
"source": "https://github.com/symfony/string/tree/v5.4.9" "source": "https://github.com/symfony/string/tree/v5.4.10"
}, },
"funding": [ "funding": [
{ {
@ -1892,22 +1892,22 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2022-04-19T10:40:37+00:00" "time": "2022-06-26T15:57:47+00:00"
} }
], ],
"packages-dev": [ "packages-dev": [
{ {
"name": "phpstan/phpstan", "name": "phpstan/phpstan",
"version": "1.7.15", "version": "1.8.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/phpstan/phpstan.git", "url": "https://github.com/phpstan/phpstan.git",
"reference": "cd0202ea1b1fc6d1bbe156c6e2e18a03e0ff160a" "reference": "b7648d4ee9321665acaf112e49da9fd93df8fbd5"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/cd0202ea1b1fc6d1bbe156c6e2e18a03e0ff160a", "url": "https://api.github.com/repos/phpstan/phpstan/zipball/b7648d4ee9321665acaf112e49da9fd93df8fbd5",
"reference": "cd0202ea1b1fc6d1bbe156c6e2e18a03e0ff160a", "reference": "b7648d4ee9321665acaf112e49da9fd93df8fbd5",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1933,7 +1933,7 @@
"description": "PHPStan - PHP Static Analysis Tool", "description": "PHPStan - PHP Static Analysis Tool",
"support": { "support": {
"issues": "https://github.com/phpstan/phpstan/issues", "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": [ "funding": [
{ {
@ -1953,7 +1953,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2022-06-20T08:29:01+00:00" "time": "2022-06-29T08:53:31+00:00"
}, },
{ {
"name": "phpstan/phpstan-deprecation-rules", "name": "phpstan/phpstan-deprecation-rules",
@ -2059,21 +2059,21 @@
}, },
{ {
"name": "phpstan/phpstan-strict-rules", "name": "phpstan/phpstan-strict-rules",
"version": "1.2.3", "version": "1.3.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/phpstan/phpstan-strict-rules.git", "url": "https://github.com/phpstan/phpstan-strict-rules.git",
"reference": "0c82c96f2a55d8b91bbc7ee6512c94f68a206b43" "reference": "543675a9be82d4befb9ca0bd8cdc9d211665037f"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan-strict-rules/zipball/0c82c96f2a55d8b91bbc7ee6512c94f68a206b43", "url": "https://api.github.com/repos/phpstan/phpstan-strict-rules/zipball/543675a9be82d4befb9ca0bd8cdc9d211665037f",
"reference": "0c82c96f2a55d8b91bbc7ee6512c94f68a206b43", "reference": "543675a9be82d4befb9ca0bd8cdc9d211665037f",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": "^7.2 || ^8.0", "php": "^7.2 || ^8.0",
"phpstan/phpstan": "^1.6.3" "phpstan/phpstan": "^1.7.15"
}, },
"require-dev": { "require-dev": {
"nikic/php-parser": "^4.13.0", "nikic/php-parser": "^4.13.0",
@ -2101,9 +2101,9 @@
"description": "Extra strict and opinionated rules for PHPStan", "description": "Extra strict and opinionated rules for PHPStan",
"support": { "support": {
"issues": "https://github.com/phpstan/phpstan-strict-rules/issues", "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", "name": "phpstan/phpstan-symfony",
@ -2178,16 +2178,16 @@
}, },
{ {
"name": "symfony/phpunit-bridge", "name": "symfony/phpunit-bridge",
"version": "v6.1.0", "version": "v6.1.2",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/phpunit-bridge.git", "url": "https://github.com/symfony/phpunit-bridge.git",
"reference": "092ccc3b364925cd8ed6046bc31dcf3a022bd5a4" "reference": "899fdec151add3dc339cf394a15100a1acc177ad"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/phpunit-bridge/zipball/092ccc3b364925cd8ed6046bc31dcf3a022bd5a4", "url": "https://api.github.com/repos/symfony/phpunit-bridge/zipball/899fdec151add3dc339cf394a15100a1acc177ad",
"reference": "092ccc3b364925cd8ed6046bc31dcf3a022bd5a4", "reference": "899fdec151add3dc339cf394a15100a1acc177ad",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -2241,7 +2241,7 @@
"description": "Provides utilities for PHPUnit, especially user deprecation notices management", "description": "Provides utilities for PHPUnit, especially user deprecation notices management",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"support": { "support": {
"source": "https://github.com/symfony/phpunit-bridge/tree/v6.1.0" "source": "https://github.com/symfony/phpunit-bridge/tree/v6.1.2"
}, },
"funding": [ "funding": [
{ {
@ -2257,7 +2257,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2022-04-12T16:22:53+00:00" "time": "2022-06-20T12:01:07+00:00"
} }
], ],
"aliases": [], "aliases": [],

View File

@ -595,16 +595,6 @@ parameters:
count: 7 count: 7
path: ../src/Composer/Command/InitCommand.php 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\\.$#" message: "#^Short ternary operator is not allowed\\. Use null coalesce operator if applicable or consider using long ternary\\.$#"
count: 2 count: 2
@ -1645,11 +1635,6 @@ parameters:
count: 1 count: 1
path: ../src/Composer/DependencyResolver/RuleSetIterator.php path: ../src/Composer/DependencyResolver/RuleSetIterator.php
-
message: "#^Only booleans are allowed in an if condition, array\\<int\\> given\\.$#"
count: 1
path: ../src/Composer/DependencyResolver/RuleWatchGraph.php
- -
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#" message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
count: 2 count: 2
@ -1675,11 +1660,6 @@ parameters:
count: 1 count: 1
path: ../src/Composer/DependencyResolver/Solver.php 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\\<Composer\\\\Package\\\\BasePackage\\> given\\.$#" message: "#^Only booleans are allowed in a negated boolean, array\\<Composer\\\\Package\\\\BasePackage\\> given\\.$#"
count: 1 count: 1
@ -1726,7 +1706,7 @@ parameters:
path: ../src/Composer/DependencyResolver/Solver.php path: ../src/Composer/DependencyResolver/Solver.php
- -
message: "#^Parameter \\#1 \\$literals of class Composer\\\\DependencyResolver\\\\GenericRule constructor expects array\\<int\\>, array\\<int, int\\|null\\> given\\.$#" message: "#^Parameter \\#1 \\$literals of class Composer\\\\DependencyResolver\\\\GenericRule constructor expects array\\<int, int\\>, array\\<int, int\\|null\\> given\\.$#"
count: 1 count: 1
path: ../src/Composer/DependencyResolver/Solver.php path: ../src/Composer/DependencyResolver/Solver.php
@ -2830,11 +2810,6 @@ parameters:
count: 1 count: 1
path: ../src/Composer/Json/JsonFile.php 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\\.$#" message: "#^Only booleans are allowed in a ternary operator condition, int given\\.$#"
count: 1 count: 1

View File

@ -244,13 +244,13 @@ abstract class BaseCommand extends Command
} }
if (true === $input->hasOption('no-dev')) { 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); $input->setOption('no-dev', true);
} }
} }
if (true === $input->hasOption('ignore-platform-reqs')) { 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); $input->setOption('ignore-platform-reqs', true);
$io->writeError('<warning>COMPOSER_IGNORE_PLATFORM_REQS is set. You may experience unexpected errors.</warning>'); $io->writeError('<warning>COMPOSER_IGNORE_PLATFORM_REQS is set. You may experience unexpected errors.</warning>');

View File

@ -234,7 +234,7 @@ abstract class BaseDependencyCommand extends BaseCommand
$color = $this->colors[$level % count($this->colors)]; $color = $this->colors[$level % count($this->colors)];
$prevColor = $this->colors[($level - 1) % 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(); $versionText = $package->getPrettyVersion() === RootPackage::DEFAULT_PRETTY_VERSION ? '' : $package->getPrettyVersion();
$packageText = rtrim(sprintf('<%s>%s</%1$s> %s', $color, $package->getPrettyName(), $versionText)); $packageText = rtrim(sprintf('<%s>%s</%1$s> %s', $color, $package->getPrettyName(), $versionText));
$linkText = sprintf('%s <%s>%s</%2$s> %s', $link->getDescription(), $prevColor, $link->getTarget(), $link->getPrettyConstraint()); $linkText = sprintf('%s <%s>%s</%2$s> %s', $link->getDescription(), $prevColor, $link->getTarget(), $link->getPrettyConstraint());

View File

@ -921,7 +921,7 @@ EOT
$id = Preg::replace('{-+}', '-', $id); $id = Preg::replace('{-+}', '-', $id);
$link = 'https://getcomposer.org/doc/06-config.md#' . $id; $link = 'https://getcomposer.org/doc/06-config.md#' . $id;
} }
if (is_string($rawVal) && $rawVal != $value) { if (is_string($rawVal) && $rawVal !== $value) {
$io->write('[<fg=yellow;href=' . $link .'>' . $k . $key . '</>] <info>' . $rawVal . ' (' . $value . ')</info>' . $source, true, IOInterface::QUIET); $io->write('[<fg=yellow;href=' . $link .'>' . $k . $key . '</>] <info>' . $rawVal . ' (' . $value . ')</info>' . $source, true, IOInterface::QUIET);
} else { } else {
$io->write('[<fg=yellow;href=' . $link .'>' . $k . $key . '</>] <info>' . $value . '</info>' . $source, true, IOInterface::QUIET); $io->write('[<fg=yellow;href=' . $link .'>' . $k . $key . '</>] <info>' . $value . '</info>' . $source, true, IOInterface::QUIET);

View File

@ -182,7 +182,7 @@ EOT
$filteredPackages = array_filter($packages, static function ($package): bool { $filteredPackages = array_filter($packages, static function ($package): bool {
return !in_array($package, array('lock', 'nothing', 'mirrors'), true); 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; $packages = $filteredPackages;
if ($updateMirrors && !empty($packages)) { if ($updateMirrors && !empty($packages)) {

View File

@ -51,13 +51,13 @@ class Compiler
} }
$process = new Process(array('git', 'log', '--pretty=%H', '-n1', 'HEAD'), __DIR__); $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.'); 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()); $this->version = trim($process->getOutput());
$process = new Process(array('git', 'log', '-n1', '--pretty=%ci', 'HEAD'), __DIR__); $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.'); 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')); $this->versionDate->setTimezone(new \DateTimeZone('UTC'));
$process = new Process(array('git', 'describe', '--tags', '--exact-match', 'HEAD'), __DIR__); $process = new Process(array('git', 'describe', '--tags', '--exact-match', 'HEAD'), __DIR__);
if ($process->run() == 0) { if ($process->run() === 0) {
$this->version = trim($process->getOutput()); $this->version = trim($process->getOutput());
} else { } else {
// get branch-alias defined in composer.json for dev-main (if any) // get branch-alias defined in composer.json for dev-main (if any)

View File

@ -311,7 +311,7 @@ class Config
return $val; 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 // booleans with env var support
case 'cache-read-only': case 'cache-read-only':

View File

@ -298,7 +298,7 @@ class Application extends BaseApplication
// Check system temp folder for usability as it can cause weird runtime issues otherwise // Check system temp folder for usability as it can cause weird runtime issues otherwise
Silencer::call(static function () use ($io): void { Silencer::call(static function () use ($io): void {
$tempfile = sys_get_temp_dir() . '/temp-' . md5(microtime()); $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('<error>PHP temp directory (%s) does not exist or is not writable to Composer. Set sys_temp_dir in your php.ini</error>', sys_get_temp_dir())); $io->writeError(sprintf('<error>PHP temp directory (%s) does not exist or is not writable to Composer. Set sys_temp_dir in your php.ini</error>', sys_get_temp_dir()));
} }
}); });

View File

@ -256,12 +256,12 @@ class Decisions implements \Iterator, \Countable
{ {
$packageId = abs($literal); $packageId = abs($literal);
$previousDecision = $this->decisionMap[$packageId] ?? null; $previousDecision = $this->decisionMap[$packageId] ?? 0;
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);
throw new SolverBugException( 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."."
); );
} }

View File

@ -17,11 +17,11 @@ namespace Composer\DependencyResolver;
*/ */
class GenericRule extends Rule class GenericRule extends Rule
{ {
/** @var int[] */ /** @var list<int> */
protected $literals; protected $literals;
/** /**
* @param int[] $literals * @param list<int> $literals
*/ */
public function __construct(array $literals, $reason, $reasonData) public function __construct(array $literals, $reason, $reasonData)
{ {
@ -34,7 +34,7 @@ class GenericRule extends Rule
} }
/** /**
* @return int[] * @return list<int>
*/ */
public function getLiterals(): array public function getLiterals(): array
{ {
@ -82,7 +82,7 @@ class GenericRule extends Rule
$result = $this->isDisabled() ? 'disabled(' : '('; $result = $this->isDisabled() ? 'disabled(' : '(';
foreach ($this->literals as $i => $literal) { foreach ($this->literals as $i => $literal) {
if ($i != 0) { if ($i !== 0) {
$result .= '|'; $result .= '|';
} }
$result .= $literal; $result .= $literal;

View File

@ -92,7 +92,7 @@ class LockTransaction extends Transaction
foreach ($packages as $package) { foreach ($packages as $package) {
foreach ($this->resultPackages['dev'] as $i => $resultPackage) { foreach ($this->resultPackages['dev'] as $i => $resultPackage) {
// TODO this comparison is probably insufficient, aliases, what about modified versions? I guess they aren't possible? // 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; $this->resultPackages['non-dev'][] = $resultPackage;
unset($this->resultPackages['dev'][$i]); 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 // 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)])) { if ($updateMirrors && !isset($this->presentMap[spl_object_hash($package)])) {
foreach ($this->presentMap as $presentPackage) { 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()) { if ($presentPackage->getSourceReference() && $presentPackage->getSourceType() === $package->getSourceType()) {
$package->setSourceDistReferences($presentPackage->getSourceReference()); $package->setSourceDistReferences($presentPackage->getSourceReference());
} }

View File

@ -19,11 +19,11 @@ namespace Composer\DependencyResolver;
*/ */
class MultiConflictRule extends Rule class MultiConflictRule extends Rule
{ {
/** @var int[] */ /** @var list<int> */
protected $literals; protected $literals;
/** /**
* @param int[] $literals * @param list<int> $literals
*/ */
public function __construct(array $literals, $reason, $reasonData) public function __construct(array $literals, $reason, $reasonData)
{ {
@ -40,7 +40,7 @@ class MultiConflictRule extends Rule
} }
/** /**
* @return int[] * @return list<int>
*/ */
public function getLiterals(): array public function getLiterals(): array
{ {
@ -102,7 +102,7 @@ class MultiConflictRule extends Rule
$result = $this->isDisabled() ? 'disabled(multi(' : '(multi('; $result = $this->isDisabled() ? 'disabled(multi(' : '(multi(';
foreach ($this->literals as $i => $literal) { foreach ($this->literals as $i => $literal) {
if ($i != 0) { if ($i !== 0) {
$result .= '|'; $result .= '|';
} }
$result .= $literal; $result .= $literal;

View File

@ -69,7 +69,7 @@ abstract class Rule
} }
/** /**
* @return int[] * @return list<int>
*/ */
abstract public function getLiterals(): array; abstract public function getLiterals(): array;
@ -380,13 +380,13 @@ abstract class Rule
$reason = null; $reason = null;
if (!isset($packageNames[$replacedName])) { 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 { } else {
$replacerNames = $packageNames; $replacerNames = $packageNames;
unset($replacerNames[$replacedName]); unset($replacerNames[$replacedName]);
$replacerNames = array_keys($replacerNames); $replacerNames = array_keys($replacerNames);
if (count($replacerNames) == 1) { if (count($replacerNames) === 1) {
$reason = $replacerNames[0] . ' replaces '; $reason = $replacerNames[0] . ' replaces ';
} else { } else {
$reason = '['.implode(', ', $replacerNames).'] replace '; $reason = '['.implode(', ', $replacerNames).'] replace ';
@ -469,7 +469,7 @@ abstract class Rule
default: default:
$ruleText = ''; $ruleText = '';
foreach ($literals as $i => $literal) { foreach ($literals as $i => $literal) {
if ($i != 0) { if ($i !== 0) {
$ruleText .= '|'; $ruleText .= '|';
} }
$ruleText .= $pool->literalToPrettyString($literal, $installedMap); $ruleText .= $pool->literalToPrettyString($literal, $installedMap);

View File

@ -44,7 +44,9 @@ class Rule2Literals extends Rule
} }
} }
/** @return int[] */ /**
* @return list<int>
*/
public function getLiterals(): array public function getLiterals(): array
{ {
return array($this->literal1, $this->literal2); return array($this->literal1, $this->literal2);
@ -82,7 +84,7 @@ class Rule2Literals extends Rule
} }
$literals = $rule->getLiterals(); $literals = $rule->getLiterals();
if (2 != \count($literals)) { if (2 !== \count($literals)) {
return false; return false;
} }

View File

@ -134,7 +134,7 @@ class RuleSetGenerator
$literals[] = -$package->id; $literals[] = -$package->id;
} }
if (\count($literals) == 2) { if (\count($literals) === 2) {
return new Rule2Literals($literals[0], $literals[1], $reason, $reasonData); return new Rule2Literals($literals[0], $literals[1], $reason, $reasonData);
} }
@ -262,7 +262,7 @@ class RuleSetGenerator
protected function addRulesForRequest(Request $request, PlatformRequirementFilterInterface $platformRequirementFilter): void protected function addRulesForRequest(Request $request, PlatformRequirementFilterInterface $platformRequirementFilter): void
{ {
foreach ($request->getFixedPackages() as $package) { 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 // fixed package was not added to the pool as it did not pass the stability requirements, this is fine
if ($this->pool->isUnacceptableFixedOrLockedPackage($package)) { if ($this->pool->isUnacceptableFixedOrLockedPackage($package)) {
continue; continue;

View File

@ -116,7 +116,7 @@ class RuleWatchGraph
!$decisions->conflict($ruleLiteral); !$decisions->conflict($ruleLiteral);
}); });
if ($alternativeLiterals) { if (\count($alternativeLiterals) > 0) {
reset($alternativeLiterals); reset($alternativeLiterals);
$this->moveWatch($literal, current($alternativeLiterals), $node); $this->moveWatch($literal, current($alternativeLiterals), $node);
continue; continue;

View File

@ -93,7 +93,7 @@ class RuleWatchNode
*/ */
public function getOtherWatch(int $literal): int public function getOtherWatch(int $literal): int
{ {
if ($this->watch1 == $literal) { if ($this->watch1 === $literal) {
return $this->watch2; return $this->watch2;
} }
@ -109,7 +109,7 @@ class RuleWatchNode
*/ */
public function moveWatch(int $from, int $to): void public function moveWatch(int $from, int $to): void
{ {
if ($this->watch1 == $from) { if ($this->watch1 === $from) {
$this->watch1 = $to; $this->watch1 = $to;
} else { } else {
$this->watch2 = $to; $this->watch2 = $to;

View File

@ -311,11 +311,11 @@ class Solver
while (true) { while (true) {
$rule = $this->propagate($level); $rule = $this->propagate($level);
if (!$rule) { if (null === $rule) {
break; break;
} }
if ($level == 1) { if ($level === 1) {
return $this->analyzeUnsolvable($rule); return $this->analyzeUnsolvable($rule);
} }
@ -523,7 +523,7 @@ class Solver
$why = spl_object_hash($conflictRule); $why = spl_object_hash($conflictRule);
$ruleSeen[$why] = true; $ruleSeen[$why] = true;
if ($conflictRule->getType() == RuleSet::TYPE_LEARNED) { if ($conflictRule->getType() === RuleSet::TYPE_LEARNED) {
$learnedWhy = $this->learnedWhy[$why]; $learnedWhy = $this->learnedWhy[$why];
$problemRules = $this->learnedPool[$learnedWhy]; $problemRules = $this->learnedPool[$learnedWhy];
@ -536,7 +536,7 @@ class Solver
return; return;
} }
if ($conflictRule->getType() == RuleSet::TYPE_PACKAGE) { if ($conflictRule->getType() === RuleSet::TYPE_PACKAGE) {
// package rules cannot be part of a problem // package rules cannot be part of a problem
return; return;
} }
@ -723,7 +723,7 @@ class Solver
$this->io->writeError('Looking at all rules.', true, IOInterface::DEBUG); $this->io->writeError('Looking at all rules.', true, IOInterface::DEBUG);
for ($i = 0, $n = 0; $n < $rulesCount; $i++, $n++) { for ($i = 0, $n = 0; $n < $rulesCount; $i++, $n++) {
if ($i == $rulesCount) { if ($i === $rulesCount) {
if (1 === $pass) { if (1 === $pass) {
$this->io->writeError("Something's changed, looking at all rules again (pass #$pass)", false, IOInterface::DEBUG); $this->io->writeError("Something's changed, looking at all rules again (pass #$pass)", false, IOInterface::DEBUG);
} else { } else {
@ -814,7 +814,7 @@ class Solver
$level = $this->setPropagateLearn($level, $lastLiteral, $why); $level = $this->setPropagateLearn($level, $lastLiteral, $why);
if ($level == 0) { if ($level === 0) {
return; return;
} }

View File

@ -73,8 +73,8 @@ class Transaction
{ {
$packageSort = static function (PackageInterface $a, PackageInterface $b): int { $packageSort = static function (PackageInterface $a, PackageInterface $b): int {
// sort alias packages by the same name behind their non alias version // sort alias packages by the same name behind their non alias version
if ($a->getName() == $b->getName()) { if ($a->getName() === $b->getName()) {
if ($a instanceof AliasPackage != $b instanceof AliasPackage) { if ($a instanceof AliasPackage !== $b instanceof AliasPackage) {
return $a instanceof AliasPackage ? -1 : 1; return $a instanceof AliasPackage ? -1 : 1;
} }
// if names are the same, compare version, e.g. to sort aliases reliably, actual order does not matter // 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? // do we need to update?
// TODO different for lock? // 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->getDistReference() !== $presentPackageMap[$package->getName()]->getDistReference() ||
$package->getSourceReference() !== $presentPackageMap[$package->getName()]->getSourceReference() $package->getSourceReference() !== $presentPackageMap[$package->getName()]->getSourceReference()
) { ) {

View File

@ -530,8 +530,8 @@ class Installer
// when mirrors/metadata from a package gets updated we do not want to list it as an // 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 // update in the output as it is only an internal lock file metadata update
if ($this->updateMirrors if ($this->updateMirrors
&& $operation->getInitialPackage()->getName() == $operation->getTargetPackage()->getName() && $operation->getInitialPackage()->getName() === $operation->getTargetPackage()->getName()
&& $operation->getInitialPackage()->getVersion() == $operation->getTargetPackage()->getVersion() && $operation->getInitialPackage()->getVersion() === $operation->getTargetPackage()->getVersion()
) { ) {
continue; continue;
} }

View File

@ -177,7 +177,7 @@ class JsonFile
private function filePutContentsIfModified(string $path, string $content) private function filePutContentsIfModified(string $path, string $content)
{ {
$currentContent = @file_get_contents($path); $currentContent = @file_get_contents($path);
if (!$currentContent || ($currentContent != $content)) { if (false === $currentContent || $currentContent !== $content) {
return file_put_contents($path, $content); return file_put_contents($path, $content);
} }

View File

@ -54,11 +54,11 @@ class GitExcludeFilter extends BaseExcludeFilter
{ {
$parts = Preg::split('#\s+#', $line); $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]); 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]); return $this->generatePattern('!'.$parts[0]);
} }

View File

@ -237,7 +237,7 @@ class VersionSelector
$semanticVersionParts = explode('.', $version); $semanticVersionParts = explode('.', $version);
// check to see if we have a semver-looking 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) // remove the last parts (i.e. the patch version number and any extra)
if ($semanticVersionParts[0] === '0') { if ($semanticVersionParts[0] === '0') {
unset($semanticVersionParts[3]); unset($semanticVersionParts[3]);
@ -250,7 +250,7 @@ class VersionSelector
} }
// append stability flag if not default // append stability flag if not default
if ($stability != 'stable') { if ($stability !== 'stable') {
$version .= '@'.$stability; $version .= '@'.$stability;
} }

View File

@ -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; return $lines;
} }

View File

@ -302,6 +302,6 @@ class AuthHelper
// {@link https://blog.bitbucket.org/2009/04/12/new-feature-downloads/} // {@link https://blog.bitbucket.org/2009/04/12/new-feature-downloads/}
$pathParts = explode('/', $path); $pathParts = explode('/', $path);
return count($pathParts) >= 4 && $pathParts[3] == 'downloads'; return count($pathParts) >= 4 && $pathParts[3] === 'downloads';
} }
} }

View File

@ -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."; $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.";
} }

View File

@ -369,7 +369,7 @@ class CurlDownloader
continue; 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; $timeoutWarning = true;
$this->io->writeError('<warning>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.</warning>'); $this->io->writeError('<warning>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.</warning>');
} }
@ -669,7 +669,7 @@ class CurlDownloader
*/ */
private function checkCurlResult(int $code): void 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( throw new \RuntimeException(
isset($this->multiErrors[$code]) isset($this->multiErrors[$code])
? "cURL error: {$code} ({$this->multiErrors[$code][0]}): cURL message: {$this->multiErrors[$code][1]}" ? "cURL error: {$code} ({$this->multiErrors[$code][0]}): cURL message: {$this->multiErrors[$code][1]}"

View File

@ -339,7 +339,7 @@ class Perforce
$resArray = explode(PHP_EOL, $result); $resArray = explode(PHP_EOL, $result);
foreach ($resArray as $line) { foreach ($resArray as $line) {
$fields = explode('=', $line); $fields = explode('=', $line);
if (strcmp($name, $fields[0]) == 0) { if (strcmp($name, $fields[0]) === 0) {
$index = strpos($fields[1], ' '); $index = strpos($fields[1], ' ');
if ($index === false) { if ($index === false) {
$value = $fields[1]; $value = $fields[1];

View File

@ -110,7 +110,7 @@ class Platform
return Preg::replaceCallback('#^(\$|(?P<percent>%))(?P<var>\w++)(?(percent)%)(?P<path>.*)#', static function ($matches): string { return Preg::replaceCallback('#^(\$|(?P<percent>%))(?P<var>\w++)(?(percent)%)(?P<path>.*)#', static function ($matches): string {
// Treat HOME as an alias for USERPROFILE on Windows for legacy reasons // 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']; return (Platform::getEnv('HOME') ?: Platform::getEnv('USERPROFILE')) . $matches['path'];
} }

View File

@ -35,7 +35,7 @@ class Zip
return null; return null;
} }
if (0 == $zip->numFiles) { if (0 === $zip->numFiles) {
$zip->close(); $zip->close();
return null; return null;

View File

@ -420,7 +420,7 @@ class InstallerTest extends TestCase
$filteredPackages = array_filter($packages, function ($package): bool { $filteredPackages = array_filter($packages, function ($package): bool {
return !in_array($package, array('lock', 'nothing', 'mirrors'), true); 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; $packages = $filteredPackages;
$updateAllowTransitiveDependencies = Request::UPDATE_ONLY_LISTED; $updateAllowTransitiveDependencies = Request::UPDATE_ONLY_LISTED;