Fix phpstan issues, update baseline and pin PHPStan version in 2.2 branch (#10474)
parent
e103ee0249
commit
e3d99cac59
|
@ -51,7 +51,7 @@ jobs:
|
|||
|
||||
- name: "Install PHPStan"
|
||||
# Locked to phpunit 7.5 here as newer ones have void return types which break inheritance
|
||||
run: "bin/composer require --dev phpstan/phpstan:^1.0 phpstan/phpstan-phpunit:^1.0 phpstan/phpstan-deprecation-rules:^1 phpstan/phpstan-strict-rules:^1 phpunit/phpunit:^7.5.20 --with-all-dependencies ${{ env.COMPOSER_FLAGS }}"
|
||||
run: "bin/composer require --dev phpstan/phpstan:1.4.* phpstan/phpstan-phpunit:1.0.* phpstan/phpstan-deprecation-rules:1.0.* phpstan/phpstan-strict-rules:1.1.* phpunit/phpunit:^7.5.20 --with-all-dependencies ${{ env.COMPOSER_FLAGS }}"
|
||||
|
||||
- name: "Run PHPStan"
|
||||
run: "vendor/bin/phpstan analyse --configuration=phpstan/config.neon"
|
||||
|
|
|
@ -83,7 +83,7 @@
|
|||
"phpstan-setup": [
|
||||
"@composer config platform --unset",
|
||||
"@composer update",
|
||||
"@composer require --dev phpstan/phpstan:^1.0 phpstan/phpstan-phpunit:^1.0 phpstan/phpstan-deprecation-rules:^1 phpstan/phpstan-strict-rules:^1 phpunit/phpunit:^7.5.20 --with-all-dependencies",
|
||||
"@composer require --dev phpstan/phpstan:1.4.* phpstan/phpstan-phpunit:1.0.* phpstan/phpstan-deprecation-rules:1.0.* phpstan/phpstan-strict-rules:1.1.* phpunit/phpunit:^7.5.20 --with-all-dependencies",
|
||||
"git checkout composer.json composer.lock"
|
||||
],
|
||||
"phpstan": "@php vendor/bin/phpstan analyse --configuration=phpstan/config.neon"
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
parameters:
|
||||
ignoreErrors:
|
||||
-
|
||||
message: "#^Argument of an invalid type array\\<string\\>\\|string supplied for foreach, only iterables are supported\\.$#"
|
||||
count: 1
|
||||
path: ../src/Composer/Autoload/AutoloadGenerator.php
|
||||
|
||||
-
|
||||
message: "#^Binary operation \"\\.\" between non\\-empty\\-string and array\\|string\\|null results in an error\\.$#"
|
||||
count: 1
|
||||
|
@ -110,11 +105,6 @@ parameters:
|
|||
count: 3
|
||||
path: ../src/Composer/Autoload/AutoloadGenerator.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#1 \\$files of method Composer\\\\Autoload\\\\AutoloadGenerator\\:\\:getIncludeFilesFile\\(\\) expects array\\<string, string\\>, array\\<int\\|string, array\\<string\\>\\|string\\> given\\.$#"
|
||||
count: 1
|
||||
path: ../src/Composer/Autoload/AutoloadGenerator.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#1 \\$from of method Composer\\\\Util\\\\Filesystem\\:\\:findShortestPathCode\\(\\) expects string, string\\|false given\\.$#"
|
||||
count: 5
|
||||
|
@ -165,11 +155,6 @@ parameters:
|
|||
count: 1
|
||||
path: ../src/Composer/Autoload/AutoloadGenerator.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#6 \\$namespaceFilter of method Composer\\\\Autoload\\\\AutoloadGenerator\\:\\:addClassMapCode\\(\\) expects string\\|null, int\\|string given\\.$#"
|
||||
count: 1
|
||||
path: ../src/Composer/Autoload/AutoloadGenerator.php
|
||||
|
||||
-
|
||||
message: "#^Short ternary operator is not allowed\\. Use null coalesce operator if applicable or consider using long ternary\\.$#"
|
||||
count: 2
|
||||
|
@ -1175,6 +1160,11 @@ parameters:
|
|||
count: 1
|
||||
path: ../src/Composer/Command/InitCommand.php
|
||||
|
||||
-
|
||||
message: "#^Property Composer\\\\Command\\\\InitCommand\\:\\:\\$gitConfig \\(array\\<string, string\\>\\) does not accept array\\<int\\|string, mixed\\>\\.$#"
|
||||
count: 1
|
||||
path: ../src/Composer/Command/InitCommand.php
|
||||
|
||||
-
|
||||
message: "#^Short ternary operator is not allowed\\. Use null coalesce operator if applicable or consider using long ternary\\.$#"
|
||||
count: 15
|
||||
|
@ -2485,11 +2475,6 @@ parameters:
|
|||
count: 1
|
||||
path: ../src/Composer/Config.php
|
||||
|
||||
-
|
||||
message: "#^Array \\(array\\<string, true\\>\\) does not accept key 0\\|string\\.$#"
|
||||
count: 1
|
||||
path: ../src/Composer/Config.php
|
||||
|
||||
-
|
||||
message: "#^Call to function array_search\\(\\) requires parameter \\#3 to be set\\.$#"
|
||||
count: 1
|
||||
|
@ -3005,11 +2990,6 @@ parameters:
|
|||
count: 2
|
||||
path: ../src/Composer/DependencyResolver/Rule.php
|
||||
|
||||
-
|
||||
message: "#^Array \\(array\\<string, array\\<Composer\\\\DependencyResolver\\\\Rule\\>\\|Composer\\\\DependencyResolver\\\\Rule\\>\\) does not accept key int\\|string\\.$#"
|
||||
count: 2
|
||||
path: ../src/Composer/DependencyResolver/RuleSet.php
|
||||
|
||||
-
|
||||
message: "#^Method Composer\\\\DependencyResolver\\\\RuleSet\\:\\:getTypes\\(\\) should return array\\{0, 1, 4\\} but returns array\\<int, 0\\|1\\|4\\>\\.$#"
|
||||
count: 1
|
||||
|
@ -3080,11 +3060,6 @@ parameters:
|
|||
count: 1
|
||||
path: ../src/Composer/DependencyResolver/Solver.php
|
||||
|
||||
-
|
||||
message: "#^Casting to int something that's already int\\.$#"
|
||||
count: 2
|
||||
path: ../src/Composer/DependencyResolver/Solver.php
|
||||
|
||||
-
|
||||
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
|
||||
count: 2
|
||||
|
@ -3100,11 +3075,6 @@ parameters:
|
|||
count: 1
|
||||
path: ../src/Composer/DependencyResolver/Solver.php
|
||||
|
||||
-
|
||||
message: "#^Only booleans are allowed in &&, int given on the left side\\.$#"
|
||||
count: 1
|
||||
path: ../src/Composer/DependencyResolver/Solver.php
|
||||
|
||||
-
|
||||
message: "#^Only booleans are allowed in &&, int\\<0, max\\> given on the right side\\.$#"
|
||||
count: 2
|
||||
|
@ -3127,7 +3097,7 @@ parameters:
|
|||
|
||||
-
|
||||
message: "#^Only booleans are allowed in a negated boolean, int given\\.$#"
|
||||
count: 3
|
||||
count: 1
|
||||
path: ../src/Composer/DependencyResolver/Solver.php
|
||||
|
||||
-
|
||||
|
@ -3980,11 +3950,6 @@ parameters:
|
|||
count: 5
|
||||
path: ../src/Composer/Factory.php
|
||||
|
||||
-
|
||||
message: "#^Array \\(array\\<string, array\\{username\\: string, password\\: string\\}\\>\\) does not accept array\\{username\\: string, password\\: string\\|null\\}\\.$#"
|
||||
count: 1
|
||||
path: ../src/Composer/IO/BaseIO.php
|
||||
|
||||
-
|
||||
message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
|
||||
count: 1
|
||||
|
@ -4050,11 +4015,6 @@ parameters:
|
|||
count: 1
|
||||
path: ../src/Composer/IO/ConsoleIO.php
|
||||
|
||||
-
|
||||
message: "#^Array \\(array\\<string, array\\<string, array\\<string, array\\<array\\<string\\>\\|bool\\|string\\>\\|bool\\|string\\>\\>\\>\\) does not accept key \\(int\\|string\\)\\.$#"
|
||||
count: 1
|
||||
path: ../src/Composer/InstalledVersions.php
|
||||
|
||||
-
|
||||
message: "#^Call to function method_exists\\(\\) with 'Composer\\\\\\\\Autoload…' and 'getRegisteredLoaders' will always evaluate to true\\.$#"
|
||||
count: 1
|
||||
|
@ -4085,11 +4045,6 @@ parameters:
|
|||
count: 15
|
||||
path: ../src/Composer/Installer.php
|
||||
|
||||
-
|
||||
message: "#^Method Composer\\\\Installer\\:\\:run\\(\\) should return 0\\|1\\|2\\|3\\|4 but returns int\\<min, \\-1\\>\\|int\\<1, max\\>\\.$#"
|
||||
count: 1
|
||||
path: ../src/Composer/Installer.php
|
||||
|
||||
-
|
||||
message: "#^Only booleans are allowed in &&, array\\<array\\<string, string\\>\\> given on the right side\\.$#"
|
||||
count: 1
|
||||
|
@ -4150,11 +4105,6 @@ parameters:
|
|||
count: 1
|
||||
path: ../src/Composer/Installer.php
|
||||
|
||||
-
|
||||
message: "#^Only booleans are allowed in an if condition, int given\\.$#"
|
||||
count: 1
|
||||
path: ../src/Composer/Installer.php
|
||||
|
||||
-
|
||||
message: "#^Only booleans are allowed in \\|\\|, array\\<string\\>\\|null given on the left side\\.$#"
|
||||
count: 2
|
||||
|
@ -4235,6 +4185,11 @@ parameters:
|
|||
count: 2
|
||||
path: ../src/Composer/Installer/InstallationManager.php
|
||||
|
||||
-
|
||||
message: "#^Constant PHP_WINDOWS_EVENT_CTRL_C not found\\.$#"
|
||||
count: 1
|
||||
path: ../src/Composer/Installer/InstallationManager.php
|
||||
|
||||
-
|
||||
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
|
||||
count: 1
|
||||
|
@ -4245,6 +4200,11 @@ parameters:
|
|||
count: 2
|
||||
path: ../src/Composer/Installer/InstallationManager.php
|
||||
|
||||
-
|
||||
message: "#^Function sapi_windows_set_ctrl_handler not found\\.$#"
|
||||
count: 3
|
||||
path: ../src/Composer/Installer/InstallationManager.php
|
||||
|
||||
-
|
||||
message: "#^Only booleans are allowed in &&, Composer\\\\EventDispatcher\\\\EventDispatcher\\|null given on the right side\\.$#"
|
||||
count: 2
|
||||
|
@ -4450,11 +4410,6 @@ parameters:
|
|||
count: 1
|
||||
path: ../src/Composer/Json/JsonFile.php
|
||||
|
||||
-
|
||||
message: "#^Only booleans are allowed in an if condition, int given\\.$#"
|
||||
count: 1
|
||||
path: ../src/Composer/Json/JsonFile.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#1 \\$json of function json_decode expects string, string\\|false given\\.$#"
|
||||
count: 1
|
||||
|
@ -4625,11 +4580,6 @@ parameters:
|
|||
count: 1
|
||||
path: ../src/Composer/Package/BasePackage.php
|
||||
|
||||
-
|
||||
message: "#^Method Composer\\\\Package\\\\Comparer\\\\Comparer\\:\\:getChanged\\(\\) should return array\\{changed\\?\\: array\\<string\\>, removed\\?\\: array\\<string\\>, added\\?\\: array\\<string\\>\\}\\|string\\|false but returns \\(non\\-empty\\-array\\<literal\\-string&non\\-empty\\-string, array\\<string\\>\\>\\)\\|string\\.$#"
|
||||
count: 1
|
||||
path: ../src/Composer/Package/Comparer/Comparer.php
|
||||
|
||||
-
|
||||
message: "#^Only booleans are allowed in &&, int\\<0, max\\>\\|false given on the right side\\.$#"
|
||||
count: 1
|
||||
|
@ -5115,11 +5065,6 @@ parameters:
|
|||
count: 1
|
||||
path: ../src/Composer/Platform/Runtime.php
|
||||
|
||||
-
|
||||
message: "#^Array \\(array\\<string, Composer\\\\Plugin\\\\PluginInterface\\>\\) does not accept object\\.$#"
|
||||
count: 2
|
||||
path: ../src/Composer/Plugin/PluginManager.php
|
||||
|
||||
-
|
||||
message: "#^Cannot call method getInstallationManager\\(\\) on Composer\\\\Composer\\|null\\.$#"
|
||||
count: 1
|
||||
|
@ -5195,21 +5140,11 @@ parameters:
|
|||
count: 1
|
||||
path: ../src/Composer/Plugin/PluginManager.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#1 \\$installer of method Composer\\\\Installer\\\\InstallationManager\\:\\:addInstaller\\(\\) expects Composer\\\\Installer\\\\InstallerInterface, object given\\.$#"
|
||||
count: 1
|
||||
path: ../src/Composer/Plugin/PluginManager.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#1 \\$path of function dirname expects string, string\\|false given\\.$#"
|
||||
count: 1
|
||||
path: ../src/Composer/Plugin/PluginManager.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#1 \\$plugin of method Composer\\\\Plugin\\\\PluginManager\\:\\:addPlugin\\(\\) expects Composer\\\\Plugin\\\\PluginInterface, object given\\.$#"
|
||||
count: 1
|
||||
path: ../src/Composer/Plugin/PluginManager.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#3 \\$subject of static method Composer\\\\Pcre\\\\Preg\\:\\:replace\\(\\) expects string, string\\|false given\\.$#"
|
||||
count: 1
|
||||
|
@ -5275,11 +5210,6 @@ parameters:
|
|||
count: 3
|
||||
path: ../src/Composer/Repository/ComposerRepository.php
|
||||
|
||||
-
|
||||
message: "#^Argument of an invalid type array\\<string, Composer\\\\Package\\\\PackageInterface\\>\\|null supplied for foreach, only iterables are supported\\.$#"
|
||||
count: 1
|
||||
path: ../src/Composer/Repository/ComposerRepository.php
|
||||
|
||||
-
|
||||
message: "#^Cannot access offset 'path' on array\\{scheme\\?\\: string, host\\?\\: string, port\\?\\: int, user\\?\\: string, pass\\?\\: string, path\\?\\: string, query\\?\\: string, fragment\\?\\: string\\}\\|false\\.$#"
|
||||
count: 1
|
||||
|
@ -5420,11 +5350,6 @@ parameters:
|
|||
count: 1
|
||||
path: ../src/Composer/Repository/ComposerRepository.php
|
||||
|
||||
-
|
||||
message: "#^Only booleans are allowed in an if condition, int given\\.$#"
|
||||
count: 1
|
||||
path: ../src/Composer/Repository/ComposerRepository.php
|
||||
|
||||
-
|
||||
message: "#^Only booleans are allowed in an if condition, string\\|false given\\.$#"
|
||||
count: 3
|
||||
|
@ -5445,11 +5370,6 @@ parameters:
|
|||
count: 1
|
||||
path: ../src/Composer/Repository/ComposerRepository.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#1 \\$input of function array_values expects array, array\\<string, Composer\\\\Package\\\\PackageInterface\\>\\|null given\\.$#"
|
||||
count: 1
|
||||
path: ../src/Composer/Repository/ComposerRepository.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#1 \\$json of function json_decode expects string, string\\|false given\\.$#"
|
||||
count: 3
|
||||
|
@ -5920,11 +5840,6 @@ parameters:
|
|||
count: 1
|
||||
path: ../src/Composer/Repository/Vcs/GitDriver.php
|
||||
|
||||
-
|
||||
message: "#^Property Composer\\\\Repository\\\\Vcs\\\\GitDriver\\:\\:\\$branches \\(array\\<string, string\\>\\) does not accept array\\<int\\|string, mixed\\>\\.$#"
|
||||
count: 1
|
||||
path: ../src/Composer/Repository/Vcs/GitDriver.php
|
||||
|
||||
-
|
||||
message: "#^Call to function array_search\\(\\) requires parameter \\#3 to be set\\.$#"
|
||||
count: 2
|
||||
|
@ -6725,11 +6640,6 @@ parameters:
|
|||
count: 2
|
||||
path: ../src/Composer/Util/Hg.php
|
||||
|
||||
-
|
||||
message: "#^Array \\(array\\<array\\{url\\: string, origin\\: string, attributes\\: array\\{retryAuthFailure\\: bool, redirects\\: int, retries\\: int, storeAuth\\: bool\\}, options\\: array, progress\\: array, curlHandle\\: resource, filename\\: string\\|false, headerHandle\\: resource, \\.\\.\\.\\}\\>\\) does not accept array\\{url\\: string, origin\\: string, attributes\\: non\\-empty\\-array\\<literal\\-string&non\\-empty\\-string, bool\\|int\\>, options\\: array, progress\\: array, curlHandle\\: resource, filename\\: string\\|null, headerHandle\\: resource\\|false, \\.\\.\\.\\}\\.$#"
|
||||
count: 1
|
||||
path: ../src/Composer/Util/Http/CurlDownloader.php
|
||||
|
||||
-
|
||||
message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
|
||||
count: 1
|
||||
|
@ -6920,6 +6830,11 @@ parameters:
|
|||
count: 1
|
||||
path: ../src/Composer/Util/Http/CurlDownloader.php
|
||||
|
||||
-
|
||||
message: "#^Property Composer\\\\Util\\\\Http\\\\CurlDownloader\\:\\:\\$jobs \\(array\\<array\\{url\\: string, origin\\: string, attributes\\: array\\{retryAuthFailure\\: bool, redirects\\: int, retries\\: int, storeAuth\\: bool\\}, options\\: array, progress\\: array, curlHandle\\: resource, filename\\: string\\|false, headerHandle\\: resource, \\.\\.\\.\\}\\>\\) does not accept non\\-empty\\-array\\<array\\{url\\: string, origin\\: string, attributes\\: array\\<literal\\-string&non\\-empty\\-string, bool\\|int\\>, options\\: array, progress\\: array, curlHandle\\: resource, filename\\: string\\|false\\|null, headerHandle\\: resource, \\.\\.\\.\\}\\>\\.$#"
|
||||
count: 1
|
||||
path: ../src/Composer/Util/Http/CurlDownloader.php
|
||||
|
||||
-
|
||||
message: "#^Property Composer\\\\Util\\\\Http\\\\CurlDownloader\\:\\:\\$multiHandle \\(resource\\|null\\) does not accept resource\\|false\\.$#"
|
||||
count: 1
|
||||
|
@ -7155,11 +7070,6 @@ parameters:
|
|||
count: 2
|
||||
path: ../src/Composer/Util/Loop.php
|
||||
|
||||
-
|
||||
message: "#^Cannot access offset int\\<min, 16\\> on array\\|false\\.$#"
|
||||
count: 6
|
||||
path: ../src/Composer/Util/NoProxyPattern.php
|
||||
|
||||
-
|
||||
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
|
||||
count: 2
|
||||
|
@ -7345,11 +7255,6 @@ parameters:
|
|||
count: 1
|
||||
path: ../src/Composer/Util/ProcessExecutor.php
|
||||
|
||||
-
|
||||
message: "#^Only booleans are allowed in &&, Composer\\\\IO\\\\IOInterface\\|null given on the left side\\.$#"
|
||||
count: 2
|
||||
path: ../src/Composer/Util/ProcessExecutor.php
|
||||
|
||||
-
|
||||
message: "#^Only booleans are allowed in &&, string\\|false given on the right side\\.$#"
|
||||
count: 2
|
||||
|
@ -7370,9 +7275,14 @@ parameters:
|
|||
count: 1
|
||||
path: ../src/Composer/Util/ProcessExecutor.php
|
||||
|
||||
-
|
||||
message: "#^Property Composer\\\\Util\\\\ProcessExecutor\\:\\:\\$jobs \\(array\\<int, array\\<string, mixed\\>\\>\\) does not accept array\\<int\\|string, array\\<string, mixed\\>\\>\\.$#"
|
||||
count: 1
|
||||
path: ../src/Composer/Util/ProcessExecutor.php
|
||||
|
||||
-
|
||||
message: "#^Short ternary operator is not allowed\\. Use null coalesce operator if applicable or consider using long ternary\\.$#"
|
||||
count: 2
|
||||
count: 1
|
||||
path: ../src/Composer/Util/ProcessExecutor.php
|
||||
|
||||
-
|
||||
|
@ -8226,16 +8136,10 @@ parameters:
|
|||
path: ../tests/Composer/Test/EventDispatcher/EventDispatcherTest.php
|
||||
|
||||
-
|
||||
message: "#^Call to function is_array\\(\\) with array\\<string, array\\{username\\: string, password\\: string\\}\\> will always evaluate to true\\.$#"
|
||||
count: 1
|
||||
path: ../tests/Composer/Test/IO/NullIOTest.php
|
||||
|
||||
-
|
||||
message:
|
||||
"""
|
||||
#^Call to deprecated method getRawData\\(\\) of class Composer\\\\InstalledVersions\\:
|
||||
Use getAllRawData\\(\\) instead which returns all datasets for all autoloaders present in the process\\. getRawData only returns the first dataset loaded, which may not be what you expect\\.$#
|
||||
"""
|
||||
message: """
|
||||
#^Call to deprecated method getRawData\\(\\) of class Composer\\\\InstalledVersions\\:
|
||||
Use getAllRawData\\(\\) instead which returns all datasets for all autoloaders present in the process\\. getRawData only returns the first dataset loaded, which may not be what you expect\\.$#
|
||||
"""
|
||||
count: 1
|
||||
path: ../tests/Composer/Test/InstalledVersionsTest.php
|
||||
|
||||
|
@ -8684,11 +8588,6 @@ parameters:
|
|||
count: 1
|
||||
path: ../tests/Composer/Test/Platform/VersionTest.php
|
||||
|
||||
-
|
||||
message: "#^Array \\(array\\<Composer\\\\Package\\\\CompletePackage\\>\\) does not accept Composer\\\\Package\\\\CompleteAliasPackage\\|Composer\\\\Package\\\\CompletePackage\\.$#"
|
||||
count: 1
|
||||
path: ../tests/Composer/Test/Plugin/PluginInstallerTest.php
|
||||
|
||||
-
|
||||
message: "#^Call to method PHPUnit\\\\Framework\\\\Assert\\:\\:assertInstanceOf\\(\\) with 'Composer\\\\\\\\Command…' and Composer\\\\Command\\\\BaseCommand will always evaluate to true\\.$#"
|
||||
count: 1
|
||||
|
|
|
@ -606,10 +606,12 @@ class Config
|
|||
}
|
||||
if ($io) {
|
||||
$host = parse_url($url, PHP_URL_HOST);
|
||||
if (!isset($this->warnedHosts[$host])) {
|
||||
$io->writeError("<warning>Warning: Accessing $host over $scheme which is an insecure protocol.</warning>");
|
||||
if (is_string($host)) {
|
||||
if (!isset($this->warnedHosts[$host])) {
|
||||
$io->writeError("<warning>Warning: Accessing $host over $scheme which is an insecure protocol.</warning>");
|
||||
}
|
||||
$this->warnedHosts[$host] = true;
|
||||
}
|
||||
$this->warnedHosts[$host] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ class RuleSet implements \IteratorAggregate, \Countable
|
|||
/** @var int */
|
||||
protected $nextRuleId = 0;
|
||||
|
||||
/** @var array<string, Rule|Rule[]> */
|
||||
/** @var array<int|string, Rule|Rule[]> */
|
||||
protected $rulesByHash = array();
|
||||
|
||||
public function __construct()
|
||||
|
|
|
@ -324,7 +324,7 @@ class Solver
|
|||
|
||||
if ($newLevel <= 0 || $newLevel >= $level) {
|
||||
throw new SolverBugException(
|
||||
"Trying to revert to invalid level ".(int) $newLevel." from level ".(int) $level."."
|
||||
"Trying to revert to invalid level ".$newLevel." from level ".$level."."
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -423,7 +423,7 @@ class Solver
|
|||
while ($l1retry) {
|
||||
$l1retry = false;
|
||||
|
||||
if (!$num && !--$l1num) {
|
||||
if (0 === $num && 0 === --$l1num) {
|
||||
// all level 1 literals done
|
||||
break 2;
|
||||
}
|
||||
|
@ -447,7 +447,7 @@ class Solver
|
|||
|
||||
unset($seen[abs($literal)]);
|
||||
|
||||
if ($num && 0 === --$num) {
|
||||
if (0 !== $num && 0 === --$num) {
|
||||
if ($literal < 0) {
|
||||
$this->testFlagLearnedPositiveLiteral = true;
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ use Psr\Log\LogLevel;
|
|||
|
||||
abstract class BaseIO implements IOInterface
|
||||
{
|
||||
/** @var array<string, array{username: string, password: string}> */
|
||||
/** @var array<string, array{username: string|null, password: string|null}> */
|
||||
protected $authentications = array();
|
||||
|
||||
/**
|
||||
|
|
|
@ -198,7 +198,7 @@ interface IOInterface extends LoggerInterface
|
|||
/**
|
||||
* Get all authentication information entered.
|
||||
*
|
||||
* @return array<string, array{username: string, password: string}> The map of authentication data
|
||||
* @return array<string, array{username: string|null, password: string|null}> The map of authentication data
|
||||
*/
|
||||
public function getAuthentications();
|
||||
|
||||
|
|
|
@ -354,7 +354,7 @@ class Installer
|
|||
$fundingCount++;
|
||||
}
|
||||
}
|
||||
if ($fundingCount) {
|
||||
if ($fundingCount > 0) {
|
||||
$this->io->writeError(array(
|
||||
sprintf(
|
||||
"<info>%d package%s you are using %s looking for funding.</info>",
|
||||
|
|
|
@ -149,7 +149,7 @@ class JsonFile
|
|||
$this->filePutContentsIfModified($this->path, static::encode($hash, $options). ($options & self::JSON_PRETTY_PRINT ? "\n" : ''));
|
||||
break;
|
||||
} catch (\Exception $e) {
|
||||
if ($retries) {
|
||||
if ($retries > 0) {
|
||||
usleep(500000);
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -67,12 +67,13 @@ class Comparer
|
|||
}
|
||||
|
||||
if ($toString) {
|
||||
$strings = array();
|
||||
foreach ($changed as $sectionKey => $itemSection) {
|
||||
foreach ($itemSection as $itemKey => $item) {
|
||||
$changed['string'][] = $item."\r\n";
|
||||
$strings[] = $item."\r\n";
|
||||
}
|
||||
}
|
||||
$changed = implode("\r\n", $changed['string']);
|
||||
$changed = implode("\r\n", $strings);
|
||||
}
|
||||
|
||||
return $changed;
|
||||
|
|
|
@ -251,7 +251,7 @@ class VersionGuesser
|
|||
// re-use the HgDriver to fetch branches (this properly includes bookmarks)
|
||||
$io = new NullIO();
|
||||
$driver = new HgDriver(array('url' => $path), $io, $this->config, new HttpDownloader($io, $this->config), $this->process);
|
||||
$branches = array_keys($driver->getBranches());
|
||||
$branches = array_map('strval', array_keys($driver->getBranches()));
|
||||
|
||||
// try to find the best (nearest) version branch to assume this feature's version
|
||||
$result = $this->guessFeatureVersion($packageConfig, $version, $branches, 'hg log -r "not ancestors(\'%candidate%\') and ancestors(\'%branch%\')" --template "{node}\\n"', $path);
|
||||
|
|
|
@ -14,6 +14,7 @@ namespace Composer\Plugin;
|
|||
|
||||
use Composer\Composer;
|
||||
use Composer\EventDispatcher\EventSubscriberInterface;
|
||||
use Composer\Installer\InstallerInterface;
|
||||
use Composer\IO\IOInterface;
|
||||
use Composer\Package\BasePackage;
|
||||
use Composer\Package\CompletePackage;
|
||||
|
@ -50,7 +51,7 @@ class PluginManager
|
|||
|
||||
/** @var array<PluginInterface> */
|
||||
protected $plugins = array();
|
||||
/** @var array<string, PluginInterface> */
|
||||
/** @var array<string, PluginInterface|InstallerInterface> */
|
||||
protected $registeredPlugins = array();
|
||||
|
||||
/**
|
||||
|
@ -284,11 +285,17 @@ class PluginManager
|
|||
}
|
||||
|
||||
if ($oldInstallerPlugin) {
|
||||
if (!is_a($class, 'Composer\Installer\InstallerInterface', true)) {
|
||||
throw new \RuntimeException('Could not activate plugin "'.$package->getName().'" as "'.$class.'" does not implement Composer\Installer\InstallerInterface');
|
||||
}
|
||||
$this->io->writeError('<warning>Loading "'.$package->getName() . '" '.($isGlobalPlugin ? '(installed globally) ' : '').'which is a legacy composer-installer built for Composer 1.x, it is likely to cause issues as you are running Composer 2.x.</warning>');
|
||||
$installer = new $class($this->io, $this->composer);
|
||||
$this->composer->getInstallationManager()->addInstaller($installer);
|
||||
$this->registeredPlugins[$package->getName()] = $installer;
|
||||
} elseif (class_exists($class)) {
|
||||
if (!is_a($class, 'Composer\Plugin\PluginInterface', true)) {
|
||||
throw new \RuntimeException('Could not activate plugin "'.$package->getName().'" as "'.$class.'" does not implement Composer\Plugin\PluginInterface');
|
||||
}
|
||||
$plugin = new $class();
|
||||
$this->addPlugin($plugin, $isGlobalPlugin, $package);
|
||||
$this->registeredPlugins[$package->getName()] = $plugin;
|
||||
|
@ -316,20 +323,15 @@ class PluginManager
|
|||
return;
|
||||
}
|
||||
|
||||
$oldInstallerPlugin = ($package->getType() === 'composer-installer');
|
||||
|
||||
if (!isset($this->registeredPlugins[$package->getName()])) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($oldInstallerPlugin) {
|
||||
/** @var \Composer\Installer\InstallerInterface $installer */
|
||||
$installer = $this->registeredPlugins[$package->getName()];
|
||||
unset($this->registeredPlugins[$package->getName()]);
|
||||
$this->composer->getInstallationManager()->removeInstaller($installer);
|
||||
$plugin = $this->registeredPlugins[$package->getName()];
|
||||
unset($this->registeredPlugins[$package->getName()]);
|
||||
if ($plugin instanceof InstallerInterface) {
|
||||
$this->composer->getInstallationManager()->removeInstaller($plugin);
|
||||
} else {
|
||||
$plugin = $this->registeredPlugins[$package->getName()];
|
||||
unset($this->registeredPlugins[$package->getName()]);
|
||||
$this->removePlugin($plugin);
|
||||
}
|
||||
}
|
||||
|
@ -352,16 +354,14 @@ class PluginManager
|
|||
return;
|
||||
}
|
||||
|
||||
$oldInstallerPlugin = ($package->getType() === 'composer-installer');
|
||||
|
||||
if (!isset($this->registeredPlugins[$package->getName()])) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($oldInstallerPlugin) {
|
||||
$plugin = $this->registeredPlugins[$package->getName()];
|
||||
if ($plugin instanceof InstallerInterface) {
|
||||
$this->deactivatePackage($package);
|
||||
} else {
|
||||
$plugin = $this->registeredPlugins[$package->getName()];
|
||||
unset($this->registeredPlugins[$package->getName()]);
|
||||
$this->removePlugin($plugin);
|
||||
$this->uninstallPlugin($plugin);
|
||||
|
|
|
@ -210,12 +210,13 @@ class ArrayRepository implements RepositoryInterface
|
|||
/**
|
||||
* Adds a new package to the repository
|
||||
*
|
||||
* @param PackageInterface $package
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addPackage(PackageInterface $package)
|
||||
{
|
||||
if (!$package instanceof BasePackage) {
|
||||
throw new \InvalidArgumentException('Only subclasses of BasePackage are supported');
|
||||
}
|
||||
if (null === $this->packages) {
|
||||
$this->initialize();
|
||||
}
|
||||
|
|
|
@ -102,7 +102,7 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
|
|||
private $rootData;
|
||||
/** @var bool */
|
||||
private $hasPartialPackages = false;
|
||||
/** @var ?array<string, PackageInterface> */
|
||||
/** @var ?array<string, mixed[]> */
|
||||
private $partialPackagesByName = null;
|
||||
|
||||
/**
|
||||
|
@ -323,7 +323,10 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
|
|||
}
|
||||
|
||||
if ($this->hasPartialPackages()) {
|
||||
return array_values($this->partialPackagesByName);
|
||||
if (!is_array($this->partialPackagesByName)) {
|
||||
throw new \LogicException('hasPartialPackages failed to initialize $this->partialPackagesByName');
|
||||
}
|
||||
return $this->createPackages($this->partialPackagesByName, 'packages.json inline packages');
|
||||
}
|
||||
|
||||
throw new \LogicException('Composer repositories that have lazy providers and no available-packages list can not load the complete list of packages, use getPackageNames instead.');
|
||||
|
@ -614,6 +617,9 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
|
|||
}
|
||||
|
||||
if ($this->hasPartialPackages()) {
|
||||
if (!is_array($this->partialPackagesByName)) {
|
||||
throw new \LogicException('hasPartialPackages failed to initialize $this->partialPackagesByName');
|
||||
}
|
||||
foreach ($this->partialPackagesByName as $versions) {
|
||||
foreach ($versions as $candidate) {
|
||||
if (isset($result[$candidate['name']]) || !isset($candidate['provide'][$packageName])) {
|
||||
|
@ -1327,7 +1333,7 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
|
|||
$filename = str_replace('http://', 'https://', $filename);
|
||||
}
|
||||
|
||||
if ($retries) {
|
||||
if ($retries > 0) {
|
||||
usleep(100000);
|
||||
|
||||
continue;
|
||||
|
|
|
@ -26,9 +26,9 @@ use Composer\Config;
|
|||
*/
|
||||
class GitDriver extends VcsDriver
|
||||
{
|
||||
/** @var array<string, string> Map of tag name to identifier */
|
||||
/** @var array<int|string, string> Map of tag name (can be turned to an int by php if it is a numeric name) to identifier */
|
||||
protected $tags;
|
||||
/** @var array<string, string> Map of branch name to identifier */
|
||||
/** @var array<int|string, string> Map of branch name (can be turned to an int by php if it is a numeric name) to identifier */
|
||||
protected $branches;
|
||||
/** @var string */
|
||||
protected $rootIdentifier;
|
||||
|
@ -172,7 +172,7 @@ class GitDriver extends VcsDriver
|
|||
$this->process->execute('git show-ref --tags --dereference', $output, $this->repoDir);
|
||||
foreach ($output = $this->process->splitLines($output) as $tag) {
|
||||
if ($tag && Preg::isMatch('{^([a-f0-9]{40}) refs/tags/(\S+?)(\^\{\})?$}', $tag, $match)) {
|
||||
$this->tags[$match[2]] = $match[1];
|
||||
$this->tags[$match[2]] = (string) $match[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ class GitLabDriver extends VcsDriver
|
|||
private $project;
|
||||
|
||||
/**
|
||||
* @var array<string, mixed[]> Keeps commits returned by GitLab API
|
||||
* @var array<string|int, mixed[]> Keeps commits returned by GitLab API as commit id => info
|
||||
*/
|
||||
private $commits = array();
|
||||
|
||||
|
|
|
@ -62,14 +62,14 @@ interface VcsDriverInterface
|
|||
/**
|
||||
* Return list of branches in the repository
|
||||
*
|
||||
* @return array<string, string> Branch names as keys, identifiers as values
|
||||
* @return array<int|string, string> Branch names as keys, identifiers as values
|
||||
*/
|
||||
public function getBranches();
|
||||
|
||||
/**
|
||||
* Return list of tags in the repository
|
||||
*
|
||||
* @return array<string, string> Tag names as keys, identifiers as values
|
||||
* @return array<int|string, string> Tag names as keys, identifiers as values
|
||||
*/
|
||||
public function getTags();
|
||||
|
||||
|
|
|
@ -223,6 +223,7 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt
|
|||
}
|
||||
|
||||
foreach ($driver->getTags() as $tag => $identifier) {
|
||||
$tag = (string) $tag;
|
||||
$msg = 'Reading composer.json of <info>' . ($this->packageName ?: $this->url) . '</info> (<comment>' . $tag . '</comment>)';
|
||||
if ($isVeryVerbose) {
|
||||
$this->io->writeError($msg);
|
||||
|
@ -330,6 +331,7 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt
|
|||
}
|
||||
|
||||
foreach ($branches as $branch => $identifier) {
|
||||
$branch = (string) $branch;
|
||||
$msg = 'Reading composer.json of <info>' . ($this->packageName ?: $this->url) . '</info> (<comment>' . $branch . '</comment>)';
|
||||
if ($isVeryVerbose) {
|
||||
$this->io->writeError($msg);
|
||||
|
|
|
@ -174,6 +174,9 @@ class CurlDownloader
|
|||
|
||||
$curlHandle = curl_init();
|
||||
$headerHandle = fopen('php://temp/maxmemory:32768', 'w+b');
|
||||
if (false === $headerHandle) {
|
||||
throw new \RuntimeException('Failed to open a temp stream to store curl headers');
|
||||
}
|
||||
|
||||
if ($copyTo) {
|
||||
$errorMessage = '';
|
||||
|
|
|
@ -159,6 +159,15 @@ class NoProxyPattern
|
|||
$net = unpack('C*', $network->ip);
|
||||
$mask = unpack('C*', $network->netmask);
|
||||
$ip = unpack('C*', $target->ip);
|
||||
if (false === $net) {
|
||||
throw new \RuntimeException('Could not parse network IP '.$network->ip);
|
||||
}
|
||||
if (false === $mask) {
|
||||
throw new \RuntimeException('Could not parse netmask '.$network->netmask);
|
||||
}
|
||||
if (false === $ip) {
|
||||
throw new \RuntimeException('Could not parse target IP '.$target->ip);
|
||||
}
|
||||
|
||||
for ($i = 1; $i < 17; ++$i) {
|
||||
if (($net[$i] & $mask[$i]) !== ($ip[$i] & $mask[$i])) {
|
||||
|
@ -304,6 +313,12 @@ class NoProxyPattern
|
|||
$mask = unpack('C*', $netmask);
|
||||
$ip = unpack('C*', $rangeIp);
|
||||
$net = '';
|
||||
if (false === $mask) {
|
||||
throw new \RuntimeException('Could not parse netmask '.$netmask);
|
||||
}
|
||||
if (false === $ip) {
|
||||
throw new \RuntimeException('Could not parse range IP '.$rangeIp);
|
||||
}
|
||||
|
||||
for ($i = 1; $i < 17; ++$i) {
|
||||
$net .= chr($ip[$i] & $mask[$i]);
|
||||
|
|
|
@ -217,8 +217,10 @@ class Svn
|
|||
$this->io->writeError("The Subversion server ({$this->url}) requested credentials:");
|
||||
|
||||
$this->hasAuth = true;
|
||||
$this->credentials['username'] = $this->io->ask("Username: ");
|
||||
$this->credentials['password'] = $this->io->askAndHideAnswer("Password: ");
|
||||
$this->credentials = array(
|
||||
'username' => (string) $this->io->ask("Username: ", ''),
|
||||
'password' => (string) $this->io->askAndHideAnswer("Password: "),
|
||||
);
|
||||
|
||||
$this->cacheCredentials = $this->io->askConfirmation("Should Subversion cache these credentials? (yes/no) ");
|
||||
|
||||
|
@ -345,8 +347,10 @@ class Svn
|
|||
|
||||
$host = parse_url($this->url, PHP_URL_HOST);
|
||||
if (isset($authConfig[$host])) {
|
||||
$this->credentials['username'] = $authConfig[$host]['username'];
|
||||
$this->credentials['password'] = $authConfig[$host]['password'];
|
||||
$this->credentials = array(
|
||||
'username' => $authConfig[$host]['username'],
|
||||
'password' => $authConfig[$host]['password'],
|
||||
);
|
||||
|
||||
return $this->hasAuth = true;
|
||||
}
|
||||
|
@ -366,8 +370,10 @@ class Svn
|
|||
return $this->hasAuth = false;
|
||||
}
|
||||
|
||||
$this->credentials['username'] = $uri['user'];
|
||||
$this->credentials['password'] = !empty($uri['pass']) ? $uri['pass'] : '';
|
||||
$this->credentials = array(
|
||||
'username' => $uri['user'],
|
||||
'password' => !empty($uri['pass']) ? $uri['pass'] : '',
|
||||
);
|
||||
|
||||
return $this->hasAuth = true;
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ class NullIOTest extends TestCase
|
|||
{
|
||||
$io = new NullIO();
|
||||
|
||||
$this->assertTrue(is_array($io->getAuthentications()));
|
||||
$this->assertTrue(is_array($io->getAuthentications())); // @phpstan-ignore-line
|
||||
$this->assertEmpty($io->getAuthentications());
|
||||
$this->assertEquals(array('username' => null, 'password' => null), $io->getAuthentication('foo'));
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ namespace Composer\Test\Plugin;
|
|||
use Composer\Composer;
|
||||
use Composer\Config;
|
||||
use Composer\Installer\PluginInstaller;
|
||||
use Composer\Package\CompleteAliasPackage;
|
||||
use Composer\Package\CompletePackage;
|
||||
use Composer\Package\Loader\JsonLoader;
|
||||
use Composer\Package\Loader\ArrayLoader;
|
||||
|
@ -44,7 +45,7 @@ class PluginInstallerTest extends TestCase
|
|||
protected $autoloadGenerator;
|
||||
|
||||
/**
|
||||
* @var CompletePackage[]
|
||||
* @var array<CompletePackage|CompleteAliasPackage>
|
||||
*/
|
||||
protected $packages;
|
||||
|
||||
|
@ -274,7 +275,7 @@ class PluginInstallerTest extends TestCase
|
|||
|
||||
/**
|
||||
* @param string $newPluginApiVersion
|
||||
* @param CompletePackage[] $plugins
|
||||
* @param array<CompletePackage|CompleteAliasPackage> $plugins
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue