1
0
Fork 0

Update to PHPStan 1.9

pull/11171/head
Jordi Boggiano 2022-11-03 21:47:26 +01:00
parent 7dfe4a38c8
commit 6c85b875f2
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
47 changed files with 169 additions and 310 deletions

72
composer.lock generated
View File

@ -226,16 +226,16 @@
},
{
"name": "composer/pcre",
"version": "2.0.0",
"version": "2.0.1",
"source": {
"type": "git",
"url": "https://github.com/composer/pcre.git",
"reference": "c8e9d27cfc5ed22643c19c160455b473ffd8aabe"
"reference": "562ca94029b37bb04205e2abb43be5550d2945d7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/composer/pcre/zipball/c8e9d27cfc5ed22643c19c160455b473ffd8aabe",
"reference": "c8e9d27cfc5ed22643c19c160455b473ffd8aabe",
"url": "https://api.github.com/repos/composer/pcre/zipball/562ca94029b37bb04205e2abb43be5550d2945d7",
"reference": "562ca94029b37bb04205e2abb43be5550d2945d7",
"shasum": ""
},
"require": {
@ -277,7 +277,7 @@
],
"support": {
"issues": "https://github.com/composer/pcre/issues",
"source": "https://github.com/composer/pcre/tree/2.0.0"
"source": "https://github.com/composer/pcre/tree/2.0.1"
},
"funding": [
{
@ -293,7 +293,7 @@
"type": "tidelift"
}
],
"time": "2022-02-25T20:05:29+00:00"
"time": "2022-11-03T15:56:01+00:00"
},
{
"name": "composer/semver",
@ -941,16 +941,16 @@
},
{
"name": "symfony/console",
"version": "v5.4.14",
"version": "v5.4.15",
"source": {
"type": "git",
"url": "https://github.com/symfony/console.git",
"reference": "984ea2c0f45f42dfed01d2f3987b187467c4b16d"
"reference": "ea59bb0edfaf9f28d18d8791410ee0355f317669"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/console/zipball/984ea2c0f45f42dfed01d2f3987b187467c4b16d",
"reference": "984ea2c0f45f42dfed01d2f3987b187467c4b16d",
"url": "https://api.github.com/repos/symfony/console/zipball/ea59bb0edfaf9f28d18d8791410ee0355f317669",
"reference": "ea59bb0edfaf9f28d18d8791410ee0355f317669",
"shasum": ""
},
"require": {
@ -1020,7 +1020,7 @@
"terminal"
],
"support": {
"source": "https://github.com/symfony/console/tree/v5.4.14"
"source": "https://github.com/symfony/console/tree/v5.4.15"
},
"funding": [
{
@ -1036,7 +1036,7 @@
"type": "tidelift"
}
],
"time": "2022-10-07T08:01:20+00:00"
"time": "2022-10-26T21:41:52+00:00"
},
{
"name": "symfony/deprecation-contracts",
@ -1950,16 +1950,16 @@
},
{
"name": "symfony/string",
"version": "v5.4.14",
"version": "v5.4.15",
"source": {
"type": "git",
"url": "https://github.com/symfony/string.git",
"reference": "089e7237497fae7a9c404d0c3aeb8db3254733e4"
"reference": "571334ce9f687e3e6af72db4d3b2a9431e4fd9ed"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/string/zipball/089e7237497fae7a9c404d0c3aeb8db3254733e4",
"reference": "089e7237497fae7a9c404d0c3aeb8db3254733e4",
"url": "https://api.github.com/repos/symfony/string/zipball/571334ce9f687e3e6af72db4d3b2a9431e4fd9ed",
"reference": "571334ce9f687e3e6af72db4d3b2a9431e4fd9ed",
"shasum": ""
},
"require": {
@ -2016,7 +2016,7 @@
"utf8"
],
"support": {
"source": "https://github.com/symfony/string/tree/v5.4.14"
"source": "https://github.com/symfony/string/tree/v5.4.15"
},
"funding": [
{
@ -2038,16 +2038,16 @@
"packages-dev": [
{
"name": "phpstan/phpstan",
"version": "1.8.11",
"version": "1.9.0",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan.git",
"reference": "46e223dd68a620da18855c23046ddb00940b4014"
"reference": "e08de53a5eec983de78a787a88e72518cf8fe43a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/46e223dd68a620da18855c23046ddb00940b4014",
"reference": "46e223dd68a620da18855c23046ddb00940b4014",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/e08de53a5eec983de78a787a88e72518cf8fe43a",
"reference": "e08de53a5eec983de78a787a88e72518cf8fe43a",
"shasum": ""
},
"require": {
@ -2077,7 +2077,7 @@
],
"support": {
"issues": "https://github.com/phpstan/phpstan/issues",
"source": "https://github.com/phpstan/phpstan/tree/1.8.11"
"source": "https://github.com/phpstan/phpstan/tree/1.9.0"
},
"funding": [
{
@ -2093,7 +2093,7 @@
"type": "tidelift"
}
],
"time": "2022-10-24T15:45:13+00:00"
"time": "2022-11-03T07:26:48+00:00"
},
{
"name": "phpstan/phpstan-deprecation-rules",
@ -2147,21 +2147,21 @@
},
{
"name": "phpstan/phpstan-phpunit",
"version": "1.1.3",
"version": "1.2.2",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan-phpunit.git",
"reference": "6b93db7fae6d6f3e81a5b4297f93af6fe4146785"
"reference": "dea1f87344c6964c607d9076dee42d891f3923f0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/6b93db7fae6d6f3e81a5b4297f93af6fe4146785",
"reference": "6b93db7fae6d6f3e81a5b4297f93af6fe4146785",
"url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/dea1f87344c6964c607d9076dee42d891f3923f0",
"reference": "dea1f87344c6964c607d9076dee42d891f3923f0",
"shasum": ""
},
"require": {
"php": "^7.2 || ^8.0",
"phpstan/phpstan": "^1.8.0"
"phpstan/phpstan": "^1.8.11"
},
"conflict": {
"phpunit/phpunit": "<7.0"
@ -2193,9 +2193,9 @@
"description": "PHPUnit extensions and rules for PHPStan",
"support": {
"issues": "https://github.com/phpstan/phpstan-phpunit/issues",
"source": "https://github.com/phpstan/phpstan-phpunit/tree/1.1.3"
"source": "https://github.com/phpstan/phpstan-phpunit/tree/1.2.2"
},
"time": "2022-10-24T11:38:17+00:00"
"time": "2022-10-28T10:23:07+00:00"
},
{
"name": "phpstan/phpstan-strict-rules",
@ -2247,16 +2247,16 @@
},
{
"name": "phpstan/phpstan-symfony",
"version": "1.2.14",
"version": "1.2.15",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan-symfony.git",
"reference": "f7dd737329504115adaa987697a759a66dd2ee8a"
"reference": "7210072b7fd83bf62eb5f889d4da70b80c07f04c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan-symfony/zipball/f7dd737329504115adaa987697a759a66dd2ee8a",
"reference": "f7dd737329504115adaa987697a759a66dd2ee8a",
"url": "https://api.github.com/repos/phpstan/phpstan-symfony/zipball/7210072b7fd83bf62eb5f889d4da70b80c07f04c",
"reference": "7210072b7fd83bf62eb5f889d4da70b80c07f04c",
"shasum": ""
},
"require": {
@ -2312,9 +2312,9 @@
"description": "Symfony Framework extensions and rules for PHPStan",
"support": {
"issues": "https://github.com/phpstan/phpstan-symfony/issues",
"source": "https://github.com/phpstan/phpstan-symfony/tree/1.2.14"
"source": "https://github.com/phpstan/phpstan-symfony/tree/1.2.15"
},
"time": "2022-10-05T11:19:29+00:00"
"time": "2022-11-03T15:03:30+00:00"
},
{
"name": "symfony/phpunit-bridge",

View File

@ -10,11 +10,6 @@ parameters:
count: 1
path: ../src/Composer/Autoload/ClassLoader.php
-
message: "#^Parameter \\#1 \\$value of function count expects array\\|Countable, array\\<string\\>\\|null given\\.$#"
count: 2
path: ../src/Composer/Command/BaseDependencyCommand.php
-
message: "#^Only booleans are allowed in an if condition, string\\|false given\\.$#"
count: 1

View File

@ -5,11 +5,6 @@ parameters:
count: 1
path: ../src/Composer/Advisory/Auditor.php
-
message: "#^Binary operation \"\\.\" between non\\-falsy\\-string and array\\|string\\|null results in an error\\.$#"
count: 1
path: ../src/Composer/Autoload/AutoloadGenerator.php
-
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
count: 10
@ -215,11 +210,6 @@ parameters:
count: 3
path: ../src/Composer/Command/BaseDependencyCommand.php
-
message: "#^Offset int does not exist on array\\<string\\>\\|null\\.$#"
count: 2
path: ../src/Composer/Command/BaseDependencyCommand.php
-
message: "#^Only booleans are allowed in a negated boolean, Composer\\\\Package\\\\BasePackage\\|null given\\.$#"
count: 1
@ -245,11 +235,6 @@ parameters:
count: 1
path: ../src/Composer/Command/BaseDependencyCommand.php
-
message: "#^Parameter \\#1 \\$var of function count expects array\\|Countable, array\\<string\\>\\|null given\\.$#"
count: 2
path: ../src/Composer/Command/BaseDependencyCommand.php
-
message: "#^Parameter \\#2 \\$commandName of class Composer\\\\Plugin\\\\CommandEvent constructor expects string, string\\|null given\\.$#"
count: 1
@ -640,11 +625,6 @@ parameters:
count: 1
path: ../src/Composer/Command/RunScriptCommand.php
-
message: "#^Only booleans are allowed in a negated boolean, int\\<0, max\\> given\\.$#"
count: 1
path: ../src/Composer/Command/RunScriptCommand.php
-
message: "#^Only booleans are allowed in a negated boolean, mixed given\\.$#"
count: 1
@ -670,11 +650,6 @@ parameters:
count: 1
path: ../src/Composer/Command/SearchCommand.php
-
message: "#^Only booleans are allowed in &&, array\\<int, array\\<string, string\\|true\\|null\\>\\> given on the left side\\.$#"
count: 1
path: ../src/Composer/Command/SearchCommand.php
-
message: "#^Only booleans are allowed in a negated boolean, Composer\\\\Composer\\|null given\\.$#"
count: 1
@ -755,16 +730,6 @@ parameters:
count: 1
path: ../src/Composer/Command/ShowCommand.php
-
message: "#^Method Composer\\\\Command\\\\ShowCommand\\:\\:appendAutoload\\(\\) should return array\\<string, array\\<string\\>\\|string\\|null\\> but returns array\\<string, array\\<array\\<int\\|string, array\\<string\\>\\|string\\>\\|string\\>\\|string\\|null\\>\\.$#"
count: 1
path: ../src/Composer/Command/ShowCommand.php
-
message: "#^Method Composer\\\\Command\\\\ShowCommand\\:\\:appendLicenses\\(\\) should return array\\<string, array\\<string\\>\\|string\\|null\\> but returns array\\<string, array\\<array\\<string, string\\>\\|string\\>\\|string\\|null\\>\\.$#"
count: 1
path: ../src/Composer/Command/ShowCommand.php
-
message: "#^Method Composer\\\\Command\\\\ShowCommand\\:\\:getPackage\\(\\) should return array\\{Composer\\\\Package\\\\CompletePackageInterface\\|null, array\\<string, string\\>\\} but returns array\\{Composer\\\\Package\\\\BasePackage\\|int\\|null, array\\<string, string\\>\\}\\.$#"
count: 1
@ -865,11 +830,6 @@ parameters:
count: 2
path: ../src/Composer/Command/ShowCommand.php
-
message: "#^Only booleans are allowed in an if condition, array\\<string, array\\<int\\|string, array\\<string\\>\\|string\\>\\> given\\.$#"
count: 2
path: ../src/Composer/Command/ShowCommand.php
-
message: "#^Only booleans are allowed in an if condition, array\\<string, string\\> given\\.$#"
count: 4
@ -900,11 +860,6 @@ parameters:
count: 2
path: ../src/Composer/Command/ShowCommand.php
-
message: "#^Parameter \\#1 \\$json of method Composer\\\\Command\\\\ShowCommand\\:\\:appendAutoload\\(\\) expects array\\<string, array\\<string\\>\\|string\\|null\\>, array\\<string, array\\<string\\|null\\>\\|string\\|false\\|null\\> given\\.$#"
count: 1
path: ../src/Composer/Command/ShowCommand.php
-
message: "#^Parameter \\#1 \\$package of method Composer\\\\Repository\\\\CompositeRepository\\:\\:hasPackage\\(\\) expects Composer\\\\Package\\\\PackageInterface, Composer\\\\Package\\\\BasePackage\\|int given\\.$#"
count: 1
@ -1275,11 +1230,6 @@ parameters:
count: 1
path: ../src/Composer/DependencyResolver/Decisions.php
-
message: "#^Offset 0 does not exist on array\\{int, Composer\\\\DependencyResolver\\\\Rule\\}\\|null\\.$#"
count: 1
path: ../src/Composer/DependencyResolver/Decisions.php
-
message: "#^Only booleans are allowed in a ternary operator condition, Composer\\\\DependencyResolver\\\\Pool\\|null given\\.$#"
count: 1
@ -1490,11 +1440,6 @@ parameters:
count: 1
path: ../src/Composer/DependencyResolver/Rule.php
-
message: "#^Method Composer\\\\DependencyResolver\\\\RuleSet\\:\\:getTypes\\(\\) should return array\\{0, 1, 4\\} but returns array\\<int, 0\\|1\\|4\\>\\.$#"
count: 1
path: ../src/Composer/DependencyResolver/RuleSet.php
-
message: "#^Only booleans are allowed in &&, Composer\\\\DependencyResolver\\\\Pool\\|null given on the right side\\.$#"
count: 1
@ -1575,11 +1520,6 @@ parameters:
count: 1
path: ../src/Composer/DependencyResolver/Solver.php
-
message: "#^Only booleans are allowed in a negated boolean, int\\|null given\\.$#"
count: 1
path: ../src/Composer/DependencyResolver/Solver.php
-
message: "#^Only booleans are allowed in an if condition, Composer\\\\DependencyResolver\\\\Rule\\|null given\\.$#"
count: 1
@ -1611,7 +1551,7 @@ parameters:
path: ../src/Composer/DependencyResolver/Solver.php
-
message: "#^Parameter \\#1 \\$literals of class Composer\\\\DependencyResolver\\\\GenericRule constructor expects array\\<int, int\\>, array\\<int, int\\|null\\> given\\.$#"
message: "#^Parameter \\#1 \\$literals of class Composer\\\\DependencyResolver\\\\GenericRule constructor expects list\\<int\\>, non\\-empty\\-list\\<int\\|null\\> given\\.$#"
count: 1
path: ../src/Composer/DependencyResolver/Solver.php
@ -2382,7 +2322,7 @@ parameters:
-
message: "#^Only booleans are allowed in a negated boolean, array\\<Composer\\\\DependencyResolver\\\\Operation\\\\OperationInterface\\> given\\.$#"
count: 2
count: 1
path: ../src/Composer/Installer.php
-
@ -2402,7 +2342,7 @@ parameters:
-
message: "#^Only booleans are allowed in an if condition, array\\<Composer\\\\DependencyResolver\\\\Operation\\\\OperationInterface\\> given\\.$#"
count: 2
count: 1
path: ../src/Composer/Installer.php
-
@ -2555,26 +2495,11 @@ parameters:
count: 1
path: ../src/Composer/Installer/InstallationManager.php
-
message: "#^Parameter \\#1 \\$onFulfilled of method React\\\\Promise\\\\PromiseInterface\\:\\:then\\(\\) expects \\(callable\\(\\)\\: mixed\\)\\|null, React\\\\Promise\\\\PromiseInterface given\\.$#"
count: 1
path: ../src/Composer/Installer/InstallationManager.php
-
message: "#^Parameter \\#2 \\$offset of function array_splice expects int, int\\|string given\\.$#"
count: 1
path: ../src/Composer/Installer/InstallationManager.php
-
message: "#^Parameter \\#3 \\$cleanupPromises of method Composer\\\\Installer\\\\InstallationManager\\:\\:executeBatch\\(\\) expects array\\<React\\\\Promise\\\\PromiseInterface\\>, array\\<\\(Closure\\)\\|React\\\\Promise\\\\PromiseInterface\\> given\\.$#"
count: 1
path: ../src/Composer/Installer/InstallationManager.php
-
message: "#^Trying to invoke React\\\\Promise\\\\PromiseInterface but it might not be a callable\\.$#"
count: 1
path: ../src/Composer/Installer/InstallationManager.php
-
message: "#^Variable method call on \\$this\\(Composer\\\\Installer\\\\InstallationManager\\)\\.$#"
count: 2
@ -2955,11 +2880,6 @@ parameters:
count: 1
path: ../src/Composer/Package/Loader/JsonLoader.php
-
message: "#^Instanceof between Composer\\\\Package\\\\RootPackage and Composer\\\\Package\\\\RootPackage will always evaluate to true\\.$#"
count: 1
path: ../src/Composer/Package/Loader/RootPackageLoader.php
-
message: "#^Only booleans are allowed in an elseif condition, string\\|null given\\.$#"
count: 1
@ -3150,11 +3070,6 @@ parameters:
count: 3
path: ../src/Composer/Package/Version/VersionGuesser.php
-
message: "#^Offset 'feature_pretty…' does not exist on array\\{version\\: non\\-falsy\\-string, commit\\: string\\|null, pretty_version\\: string\\|null, feature_version\\: non\\-falsy\\-string, feature_pretty_version\\?\\: string\\|null\\}\\.$#"
count: 1
path: ../src/Composer/Package/Version/VersionGuesser.php
-
message: "#^Only booleans are allowed in &&, string given on the left side\\.$#"
count: 2
@ -3515,11 +3430,6 @@ parameters:
count: 3
path: ../src/Composer/Repository/CompositeRepository.php
-
message: "#^Only booleans are allowed in a ternary operator condition, array\\<int, array\\<int, array\\<string, string\\|true\\|null\\>\\>\\> given\\.$#"
count: 1
path: ../src/Composer/Repository/CompositeRepository.php
-
message: "#^Only booleans are allowed in a ternary operator condition, array\\<int, array\\<string, array\\<string, string\\>\\>\\> given\\.$#"
count: 1
@ -4163,11 +4073,6 @@ parameters:
count: 1
path: ../src/Composer/Repository/VcsRepository.php
-
message: "#^Only booleans are allowed in &&, array\\<string\\> given on the right side\\.$#"
count: 1
path: ../src/Composer/Repository/VcsRepository.php
-
message: "#^Only booleans are allowed in a negated boolean, Composer\\\\Package\\\\Loader\\\\LoaderInterface\\|null given\\.$#"
count: 1
@ -4303,11 +4208,6 @@ parameters:
count: 1
path: ../src/Composer/Util/Bitbucket.php
-
message: "#^Offset 'access_token' does not exist on array\\{access_token\\: string, expires_in\\?\\: int\\}\\|null\\.$#"
count: 1
path: ../src/Composer/Util/Bitbucket.php
-
message: "#^Only booleans are allowed in a negated boolean, string given\\.$#"
count: 2
@ -5363,11 +5263,6 @@ parameters:
count: 1
path: ../tests/Composer/Test/DependencyResolver/PoolBuilderTest.php
-
message: "#^Method Composer\\\\Test\\\\DependencyResolver\\\\PoolBuilderTest\\:\\:getPackageResultSet\\(\\) should return array\\<string\\> but returns array\\<int, int\\<min, \\-1\\>\\|int\\<1, max\\>\\|string\\>\\.$#"
count: 1
path: ../tests/Composer/Test/DependencyResolver/PoolBuilderTest.php
-
message: "#^Only booleans are allowed in an if condition, int\\|false given\\.$#"
count: 2
@ -5686,36 +5581,6 @@ parameters:
count: 1
path: ../tests/Composer/Test/Package/Loader/ValidatingArrayLoaderTest.php
-
message: "#^Offset 'commit' does not exist on array\\{version\\: string, commit\\: string\\|null, pretty_version\\: string\\|null, feature_version\\?\\: string\\|null, feature_pretty_version\\?\\: string\\|null\\}\\|null\\.$#"
count: 6
path: ../tests/Composer/Test/Package/Version/VersionGuesserTest.php
-
message: "#^Offset 'feature_pretty…' does not exist on array\\{version\\: string, commit\\: string\\|null, pretty_version\\: string\\|null, feature_version\\?\\: string\\|null, feature_pretty_version\\?\\: string\\|null\\}\\|null\\.$#"
count: 2
path: ../tests/Composer/Test/Package/Version/VersionGuesserTest.php
-
message: "#^Offset 'feature_version' does not exist on array\\{version\\: string, commit\\: string\\|null, pretty_version\\: string\\|null, feature_version\\?\\: string\\|null, feature_pretty_version\\?\\: string\\|null\\}\\|null\\.$#"
count: 2
path: ../tests/Composer/Test/Package/Version/VersionGuesserTest.php
-
message: "#^Offset 'pretty_version' does not exist on array\\{version\\: string, commit\\: string\\|null, pretty_version\\: string\\|null, feature_version\\?\\: string\\|null, feature_pretty_version\\?\\: string\\|null\\}\\|null\\.$#"
count: 5
path: ../tests/Composer/Test/Package/Version/VersionGuesserTest.php
-
message: "#^Offset 'version' does not exist on array\\{version\\: string, commit\\: string\\|null, pretty_version\\: string\\|null, feature_version\\?\\: string\\|null, feature_pretty_version\\?\\: string\\|null\\}\\|null\\.$#"
count: 14
path: ../tests/Composer/Test/Package/Version/VersionGuesserTest.php
-
message: "#^Parameter \\#2 \\$array of method PHPUnit\\\\Framework\\\\Assert\\:\\:assertArrayNotHasKey\\(\\) expects array\\|ArrayAccess, array\\<string, string\\|null\\>\\|null given\\.$#"
count: 4
path: ../tests/Composer/Test/Package/Version/VersionGuesserTest.php
-
message: "#^Only booleans are allowed in an if condition, string\\|null given\\.$#"
count: 1
@ -5736,21 +5601,6 @@ parameters:
count: 1
path: ../tests/Composer/Test/Plugin/PluginInstallerTest.php
-
message: "#^Call to method PHPUnit\\\\Framework\\\\Assert\\:\\:assertInstanceOf\\(\\) with 'Composer\\\\\\\\Plugin…' and Composer\\\\Plugin\\\\Capability\\\\CommandProvider will always evaluate to true\\.$#"
count: 1
path: ../tests/Composer/Test/Plugin/PluginInstallerTest.php
-
message: "#^Call to method PHPUnit\\\\Framework\\\\Assert\\:\\:assertInstanceOf\\(\\) with 'Composer\\\\\\\\Plugin…' and Composer\\\\Test\\\\Plugin\\\\Mock\\\\Capability will always evaluate to true\\.$#"
count: 1
path: ../tests/Composer/Test/Plugin/PluginInstallerTest.php
-
message: "#^Call to method PHPUnit\\\\Framework\\\\Assert\\:\\:assertInstanceOf\\(\\) with 'Composer\\\\\\\\Test…' and Composer\\\\Test\\\\Plugin\\\\Mock\\\\Capability will always evaluate to true\\.$#"
count: 1
path: ../tests/Composer/Test/Plugin/PluginInstallerTest.php
-
message: "#^Parameter \\#2 \\$capabilityClassName of method Composer\\\\Plugin\\\\PluginManager\\:\\:getPluginCapability\\(\\) expects class\\-string\\<Composer\\\\Plugin\\\\Capability\\\\Capability\\>, string given\\.$#"
count: 2
@ -5801,31 +5651,11 @@ parameters:
count: 1
path: ../tests/Composer/Test/Repository/PathRepositoryTest.php
-
message: "#^Call to method PHPUnit\\\\Framework\\\\Assert\\:\\:assertInstanceOf\\(\\) with 'Composer\\\\\\\\Repository…' and Composer\\\\Repository\\\\FilterRepository will always evaluate to true\\.$#"
count: 1
path: ../tests/Composer/Test/Repository/RepositoryManagerTest.php
-
message: "#^Call to method PHPUnit\\\\Framework\\\\Assert\\:\\:assertInstanceOf\\(\\) with 'Composer\\\\\\\\Repository…' and Composer\\\\Repository\\\\RepositoryInterface will always evaluate to true\\.$#"
count: 1
path: ../tests/Composer/Test/Repository/RepositoryManagerTest.php
-
message: "#^Offset 'reference' does not exist on array\\{type\\: string, url\\: string, reference\\: string, shasum\\: string\\}\\|null\\.$#"
count: 4
path: ../tests/Composer/Test/Repository/Vcs/GitHubDriverTest.php
-
message: "#^Offset 'type' does not exist on array\\{type\\: string, url\\: string, reference\\: string, shasum\\: string\\}\\|null\\.$#"
count: 4
path: ../tests/Composer/Test/Repository/Vcs/GitHubDriverTest.php
-
message: "#^Offset 'url' does not exist on array\\{type\\: string, url\\: string, reference\\: string, shasum\\: string\\}\\|null\\.$#"
count: 4
path: ../tests/Composer/Test/Repository/Vcs/GitHubDriverTest.php
-
message: "#^Parameter \\#1 \\$objectOrValue of method ReflectionProperty\\:\\:setValue\\(\\) expects object\\|null, object\\|string given\\.$#"
count: 1
@ -5836,11 +5666,6 @@ parameters:
count: 1
path: ../tests/Composer/Test/Repository/Vcs/PerforceDriverTest.php
-
message: "#^Call to method PHPUnit\\\\Framework\\\\Assert\\:\\:assertEmpty\\(\\) with array\\<'0\\.6\\.0'\\|'1\\.0\\.0'\\|'1\\.0\\.x\\-dev'\\|'1\\.1\\.x\\-dev'\\|'9999999\\-dev'\\|'dev\\-feature\\-b'\\|'dev\\-feature/a\\-1\\.0\\-B'\\|'dev\\-master', true\\> and literal\\-string&non\\-falsy\\-string will always evaluate to false\\.$#"
count: 1
path: ../tests/Composer/Test/Repository/VcsRepositoryTest.php
-
message: "#^Only booleans are allowed in a negated boolean, string given\\.$#"
count: 1
@ -5876,6 +5701,11 @@ parameters:
count: 1
path: ../tests/Composer/Test/TestCase.php
-
message: "#^Cannot access an offset on array\\<int, array\\<string, int\\|string\\>\\>\\|false\\.$#"
count: 1
path: ../tests/Composer/Test/Util/GitTest.php
-
message: "#^Call to method PHPUnit\\\\Framework\\\\Assert\\:\\:assertInstanceOf\\(\\) with 'Composer\\\\\\\\Util\\\\\\\\Http…' and Composer\\\\Util\\\\Http\\\\ProxyManager will always evaluate to true\\.$#"
count: 1
@ -5971,11 +5801,6 @@ parameters:
count: 2
path: ../tests/Composer/Test/Util/TlsHelperTest.php
-
message: "#^Offset 'cn' does not exist on array\\{cn\\: string, san\\: array\\<string\\>\\}\\|null\\.$#"
count: 1
path: ../tests/Composer/Test/Util/TlsHelperTest.php
-
message: "#^Only booleans are allowed in a ternary operator condition, array\\<string\\> given\\.$#"
count: 1

View File

@ -41,7 +41,7 @@ abstract class BaseDependencyCommand extends BaseCommand
protected const OPTION_RECURSIVE = 'recursive';
protected const OPTION_TREE = 'tree';
/** @var ?string[] */
/** @var string[] */
protected $colors;
/**

View File

@ -38,7 +38,7 @@ trait CompletionTrait
/**
* Suggestion values for "prefer-install" option
*
* @return string[]
* @return list<string>
*/
private function suggestPreferInstall(): array
{

View File

@ -63,7 +63,7 @@ EOT
}
$io = $this->getIO();
/** @var string $binary */
/** @var int $binary */
$binary = $io->select(
'Binary to run: ',
$binaries,
@ -123,7 +123,7 @@ EOT
}
/**
* @return string[]
* @return list<string>
*/
private function getBinaries(bool $forDisplay): array
{

View File

@ -33,9 +33,9 @@ class GlobalCommand extends BaseCommand
{
$application = $this->getApplication();
if ($input->mustSuggestArgumentValuesFor('command-name')) {
$suggestions->suggestValues(array_filter(array_map(static function (Command $command) {
$suggestions->suggestValues(array_values(array_filter(array_map(static function (Command $command) {
return $command->isHidden() ? null : $command->getName();
}, $application->all())));
}, $application->all()))));
return;
}

View File

@ -95,7 +95,7 @@ EOT
$results = $repos->search($query, $mode, $type);
if ($results && $format === 'text') {
if (\count($results) > 0 && $format === 'text') {
$width = $this->getTerminalWidth();
$nameLength = 0;

View File

@ -55,6 +55,9 @@ use Symfony\Component\Console\Output\OutputInterface;
* @author Jordi Boggiano <j.boggiano@seld.be>
* @author Jérémy Romey <jeremyFreeAgent>
* @author Mihai Plasoianu <mihai@plasoianu.de>
*
* @phpstan-import-type AutoloadRules from PackageInterface
* @phpstan-type JsonStructure array<string, null|string|array<string|null>|AutoloadRules>
*/
class ShowCommand extends BaseCommand
{
@ -820,7 +823,7 @@ EOT
}
}
if ($package->getAutoload()) {
if (\count($package->getAutoload()) > 0) {
$io->write("\n<info>autoload</info>");
$autoloadConfig = $package->getAutoload();
foreach ($autoloadConfig as $type => $autoloads) {
@ -955,9 +958,9 @@ EOT
}
if ($installedRepo->hasPackage($package)) {
$json['path'] = realpath($this->requireComposer()->getInstallationManager()->getInstallPath($package));
if ($json['path'] === false) {
unset($json['path']);
$path = realpath($this->requireComposer()->getInstallationManager()->getInstallPath($package));
if ($path !== false) {
$json['path'] = $path;
}
}
@ -985,9 +988,9 @@ EOT
}
/**
* @param array<string, string|string[]|null> $json
* @param JsonStructure $json
* @param array<string, string> $versions
* @return array<string, string|string[]|null>
* @return JsonStructure
*/
private function appendVersions(array $json, array $versions): array
{
@ -999,8 +1002,8 @@ EOT
}
/**
* @param array<string, string|string[]|null> $json
* @return array<string, string|string[]|null>
* @param JsonStructure $json
* @return JsonStructure
*/
private function appendLicenses(array $json, CompletePackageInterface $package): array
{
@ -1026,12 +1029,12 @@ EOT
}
/**
* @param array<string, string|string[]|null> $json
* @return array<string, string|string[]|null>
* @param JsonStructure $json
* @return JsonStructure
*/
private function appendAutoload(array $json, CompletePackageInterface $package): array
{
if ($package->getAutoload()) {
if (\count($package->getAutoload()) > 0) {
$autoload = [];
foreach ($package->getAutoload() as $type => $autoloads) {
@ -1059,8 +1062,8 @@ EOT
}
/**
* @param array<string, string|string[]|null> $json
* @return array<string, string|string[]|null>
* @param JsonStructure $json
* @return JsonStructure
*/
private function appendLinks(array $json, CompletePackageInterface $package): array
{
@ -1072,8 +1075,8 @@ EOT
}
/**
* @param array<string, string|string[]|null> $json
* @return array<string, string|string[]|null>
* @param JsonStructure $json
* @return JsonStructure
*/
private function appendLink(array $json, CompletePackageInterface $package, string $linkType): array
{

View File

@ -496,6 +496,7 @@ class Config
}
return Preg::replaceCallback('#\{\$(.+)\}#', function ($match) use ($flags) {
assert(is_string($match[1]));
return $this->get($match[1], $flags);
}, $value);
}

View File

@ -403,17 +403,7 @@ class Application extends BaseApplication
$this->renderThrowable($e, $output);
}
$exitCode = $e->getCode();
if (is_numeric($exitCode)) {
$exitCode = (int) $exitCode;
if (0 === $exitCode) {
$exitCode = 1;
}
} else {
$exitCode = 1;
}
return $exitCode;
return max(1, $e->getCode());
}
throw $e;

View File

@ -75,10 +75,11 @@ class HtmlOutputFormatter extends OutputFormatter
}
/**
* @param string[] $matches
* @param array<string|null> $matches
*/
private function formatHtml(array $matches): string
{
assert(is_string($matches[1]));
$out = '<span style="';
foreach (explode(';', $matches[1]) as $code) {
if (isset(self::$availableForegroundColors[(int) $code])) {

View File

@ -31,7 +31,7 @@ use Symfony\Component\Console\Input\InputArgument as BaseInputArgument;
class InputArgument extends BaseInputArgument
{
/**
* @var string[]|\Closure(CompletionInput,CompletionSuggestions):list<string|Suggestion>
* @var list<string>|\Closure(CompletionInput,CompletionSuggestions):list<string|Suggestion>
*/
private $suggestedValues;
@ -40,7 +40,7 @@ class InputArgument extends BaseInputArgument
* @param int|null $mode The argument mode: self::REQUIRED or self::OPTIONAL
* @param string $description A description text
* @param string|bool|int|float|string[]|null $default The default value (for self::OPTIONAL mode only)
* @param string[]|\Closure(CompletionInput,CompletionSuggestions):list<string|Suggestion> $suggestedValues The values used for input completion
* @param list<string>|\Closure(CompletionInput,CompletionSuggestions):list<string|Suggestion> $suggestedValues The values used for input completion
*
* @throws InvalidArgumentException When argument mode is not valid
*/

View File

@ -31,7 +31,7 @@ use Symfony\Component\Console\Input\InputOption as BaseInputOption;
class InputOption extends BaseInputOption
{
/**
* @var string[]|\Closure(CompletionInput,CompletionSuggestions):list<string|Suggestion>
* @var list<string>|\Closure(CompletionInput,CompletionSuggestions):list<string|Suggestion>
*/
private $suggestedValues;
@ -39,7 +39,7 @@ class InputOption extends BaseInputOption
* @param string|string[]|null $shortcut The shortcuts, can be null, a string of shortcuts delimited by | or an array of shortcuts
* @param int|null $mode The option mode: One of the VALUE_* constants
* @param string|bool|int|float|string[]|null $default The default value (must be null for self::VALUE_NONE)
* @param string[]|\Closure(CompletionInput,CompletionSuggestions):list<string|Suggestion> $suggestedValues The values used for input completionnull for self::VALUE_NONE)
* @param list<string>|\Closure(CompletionInput,CompletionSuggestions):list<string|Suggestion> $suggestedValues The values used for input completionnull for self::VALUE_NONE)
*
* @throws InvalidArgumentException If option mode is invalid or incompatible
*/

View File

@ -137,6 +137,9 @@ class Decisions implements \Iterator, \Countable
}
}
/**
* @param int<-1, max> $offset
*/
public function resetToOffset(int $offset): void
{
while (\count($this->decisionQueue) > $offset + 1) {

View File

@ -127,8 +127,8 @@ class LockTransaction extends Transaction
/**
* Checks which of the given aliases from composer.json are actually in use for the lock file
* @param array<array{package: string, version: string, alias: string, alias_normalized: string}> $aliases
* @return array<array{package: string, version: string, alias: string, alias_normalized: string}>
* @param list<array{package: string, version: string, alias: string, alias_normalized: string}> $aliases
* @return list<array{package: string, version: string, alias: string, alias_normalized: string}>
*/
public function getAliases(array $aliases): array
{

View File

@ -452,13 +452,13 @@ class Problem
}
/**
* @param string[] $versions an array of pretty versions, with normalized versions as keys
* @param array<string, string> $versions an array of pretty versions, with normalized versions as keys
* @return list<string> a list of pretty versions and '...' where versions were removed
*/
private static function condenseVersionList(array $versions, int $max, int $maxDev = 16): array
{
if (count($versions) <= $max) {
return $versions;
return array_values($versions);
}
$filtered = [];

View File

@ -17,6 +17,8 @@ use Composer\Repository\RepositorySet;
/**
* @author Nils Adermann <naderman@naderman.de>
* @implements \IteratorAggregate<Rule>
* @internal
* @final
*/
class RuleSet implements \IteratorAggregate, \Countable
{
@ -32,8 +34,7 @@ class RuleSet implements \IteratorAggregate, \Countable
*/
public $ruleById = [];
/** @var array<0|1|4, string> */
protected static $types = [
const TYPES = [
self::TYPE_PACKAGE => 'PACKAGE',
self::TYPE_REQUEST => 'REQUEST',
self::TYPE_LEARNED => 'LEARNED',
@ -60,7 +61,7 @@ class RuleSet implements \IteratorAggregate, \Countable
*/
public function add(Rule $rule, $type): void
{
if (!isset(self::$types[$type])) {
if (!isset(self::TYPES[$type])) {
throw new \OutOfBoundsException('Unknown rule type: ' . $type);
}
@ -162,10 +163,12 @@ class RuleSet implements \IteratorAggregate, \Countable
return new RuleSetIterator($rules);
}
/** @return array{0: 0, 1: 1, 2: 4} */
/**
* @return array{self::TYPE_PACKAGE, self::TYPE_REQUEST, self::TYPE_LEARNED}
*/
public function getTypes(): array
{
$types = self::$types;
$types = self::TYPES;
return array_keys($types);
}
@ -174,7 +177,7 @@ class RuleSet implements \IteratorAggregate, \Countable
{
$string = "\n";
foreach ($this->rules as $type => $rules) {
$string .= str_pad(self::$types[$type], 8, ' ') . ": ";
$string .= str_pad(self::TYPES[$type], 8, ' ') . ": ";
foreach ($rules as $rule) {
$string .= ($repositorySet && $request && $pool ? $rule->getPrettyString($repositorySet, $request, $pool, $isVerbose) : $rule)."\n";
}

View File

@ -475,7 +475,7 @@ class Solver
$why = \count($this->learnedPool) - 1;
if (!$learnedLiterals[0]) {
if (null === $learnedLiterals[0]) {
throw new SolverBugException(
"Did not find a learnable literal in analyzed rule $analyzedRule."
);

View File

@ -342,7 +342,7 @@ class EventDispatcher
$pathAndArgs = substr($exec, 5);
if (Platform::isWindows()) {
$pathAndArgs = Preg::replaceCallback('{^\S+}', static function ($path) {
return str_replace('/', '\\', $path[0]);
return str_replace('/', '\\', (string) $path[0]);
}, $pathAndArgs);
}
// match somename (not in quote, and not a qualified path) and if it is not a valid path from CWD then try to find it
@ -364,6 +364,8 @@ class EventDispatcher
if (Platform::isWindows()) {
$exec = Preg::replaceCallback('{^\S+}', static function ($path) {
assert(is_string($path[0]));
return str_replace('/', '\\', $path[0]);
}, $exec);
}

View File

@ -52,6 +52,8 @@ class BufferIO extends ConsoleIO
$output = stream_get_contents($this->output->getStream());
$output = Preg::replaceCallback("{(?<=^|\n|\x08)(.+?)(\x08+)}", static function ($matches): string {
assert(is_string($matches[1]));
assert(is_string($matches[2]));
$pre = strip_tags($matches[1]);
if (strlen($pre) === strlen($matches[2])) {

View File

@ -68,6 +68,8 @@ class JsonFormatter
if ($unescapeUnicode && function_exists('mb_convert_encoding')) {
// https://stackoverflow.com/questions/2934563/how-to-decode-unicode-escape-sequences-like-u00ed-to-proper-utf-8-encoded-cha
$buffer = Preg::replaceCallback('/(\\\\+)u([0-9a-f]{4})/i', static function ($match) {
assert(is_string($match[1]));
assert(is_string($match[2]));
$l = strlen($match[1]);
if ($l % 2) {

View File

@ -261,7 +261,7 @@ class JsonManipulator
$childRegex = '{'.self::$DEFINES.'(?P<start>"'.preg_quote($name).'"\s*:\s*)(?P<content>(?&json))(?P<end>,?)}x';
if (Preg::isMatch($childRegex, $children, $matches)) {
$children = Preg::replaceCallback($childRegex, function ($matches) use ($subName, $value): string {
if ($subName !== null) {
if ($subName !== null && is_string($matches['content'])) {
$curVal = json_decode($matches['content'], true);
if (!is_array($curVal)) {
$curVal = [];
@ -410,6 +410,7 @@ class JsonManipulator
}
$this->contents = Preg::replaceCallback($nodeRegex, function ($matches) use ($name, $subName, $childrenClean): string {
assert(is_string($matches['content']));
if ($subName !== null) {
$curVal = json_decode($matches['content'], true);
unset($curVal[$name][$subName]);

View File

@ -75,7 +75,7 @@ class ArrayLoader implements LoaderInterface
}
/**
* @param list<array<mixed>> $versions
* @param array<array<mixed>> $versions
*
* @return list<CompletePackage|CompleteAliasPackage>
*/

View File

@ -17,16 +17,16 @@ namespace Composer\Package\Loader;
*/
class InvalidPackageException extends \Exception
{
/** @var string[] */
/** @var list<string> */
private $errors;
/** @var string[] */
/** @var list<string> */
private $warnings;
/** @var mixed[] package config */
private $data;
/**
* @param string[] $errors
* @param string[] $warnings
* @param list<string> $errors
* @param list<string> $warnings
* @param mixed[] $data
*/
public function __construct(array $errors, array $warnings, array $data)
@ -46,7 +46,7 @@ class InvalidPackageException extends \Exception
}
/**
* @return string[]
* @return list<string>
*/
public function getErrors(): array
{
@ -54,7 +54,7 @@ class InvalidPackageException extends \Exception
}
/**
* @return string[]
* @return list<string>
*/
public function getWarnings(): array
{

View File

@ -32,9 +32,9 @@ class ValidatingArrayLoader implements LoaderInterface
private $loader;
/** @var VersionParser */
private $versionParser;
/** @var string[] */
/** @var list<string> */
private $errors;
/** @var string[] */
/** @var list<string> */
private $warnings;
/** @var mixed[] */
private $config;
@ -428,7 +428,7 @@ class ValidatingArrayLoader implements LoaderInterface
}
/**
* @return string[]
* @return list<string>
*/
public function getWarnings(): array
{
@ -436,7 +436,7 @@ class ValidatingArrayLoader implements LoaderInterface
}
/**
* @return string[]
* @return list<string>
*/
public function getErrors(): array
{

View File

@ -38,7 +38,7 @@ class Package extends BasePackage
protected $sourceUrl;
/** @var ?string */
protected $sourceReference;
/** @var ?array<int, array{url: non-empty-string, preferred: bool}> */
/** @var ?list<array{url: non-empty-string, preferred: bool}> */
protected $sourceMirrors;
/** @var ?non-empty-string */
protected $distType;
@ -48,7 +48,7 @@ class Package extends BasePackage
protected $distReference;
/** @var ?string */
protected $distSha1Checksum;
/** @var ?array<int, array{url: non-empty-string, preferred: bool}> */
/** @var ?list<array{url: non-empty-string, preferred: bool}> */
protected $distMirrors;
/** @var string */
protected $version;
@ -658,7 +658,7 @@ class Package extends BasePackage
/**
* @param mixed[]|null $mirrors
*
* @return non-empty-string[]
* @return list<non-empty-string>
*
* @phpstan-param list<array{url: non-empty-string, preferred: bool}>|null $mirrors
*/

View File

@ -127,7 +127,7 @@ interface PackageInterface
/**
* Returns the repository urls of this package including mirrors, e.g. git://github.com/naderman/composer.git
*
* @return string[]
* @return list<string>
*/
public function getSourceUrls(): array;
@ -141,12 +141,12 @@ interface PackageInterface
/**
* Returns the source mirrors of this package
*
* @return ?array<int, array{url: non-empty-string, preferred: bool}>
* @return ?list<array{url: non-empty-string, preferred: bool}>
*/
public function getSourceMirrors(): ?array;
/**
* @param null|array<int, array{url: non-empty-string, preferred: bool}> $mirrors
* @param null|list<array{url: non-empty-string, preferred: bool}> $mirrors
*/
public function setSourceMirrors(?array $mirrors): void;
@ -188,12 +188,12 @@ interface PackageInterface
/**
* Returns the dist mirrors of this package
*
* @return ?array<int, array{url: non-empty-string, preferred: bool}>
* @return ?list<array{url: non-empty-string, preferred: bool}>
*/
public function getDistMirrors(): ?array;
/**
* @param null|array<int, array{url: non-empty-string, preferred: bool}> $mirrors
* @param null|list<array{url: non-empty-string, preferred: bool}> $mirrors
*/
public function setDistMirrors(?array $mirrors): void;

View File

@ -31,7 +31,7 @@ class RootPackage extends CompletePackage implements RootPackageInterface
protected $config = [];
/** @var array<string, string> Map of package name to reference/commit hash */
protected $references = [];
/** @var array<array{package: string, version: string, alias: string, alias_normalized: string}> */
/** @var list<array{package: string, version: string, alias: string, alias_normalized: string}> */
protected $aliases = [];
/**

View File

@ -27,7 +27,7 @@ interface RootPackageInterface extends CompletePackageInterface
/**
* Returns a set of package names and their aliases
*
* @return array<array{package: string, version: string, alias: string, alias_normalized: string}>
* @return list<array{package: string, version: string, alias: string, alias_normalized: string}>
*/
public function getAliases(): array;
@ -151,7 +151,7 @@ interface RootPackageInterface extends CompletePackageInterface
/**
* Set the aliases
*
* @param array<array{package: string, version: string, alias: string, alias_normalized: string}> $aliases
* @param list<array{package: string, version: string, alias: string, alias_normalized: string}> $aliases
*/
public function setAliases(array $aliases): void;

View File

@ -31,7 +31,7 @@ use Symfony\Component\Process\Process;
* @author Jordi Boggiano <j.boggiano@seld.be>
* @author Samuel Roze <samuel.roze@gmail.com>
*
* @phpstan-type Version array{version: string, commit: string|null, pretty_version: string|null, feature_version?: string|null, feature_pretty_version?: string|null}
* @phpstan-type Version array{version: string, commit: string|null, pretty_version: string|null}|array{version: string, commit: string|null, pretty_version: string|null, feature_version: string|null, feature_pretty_version: string|null}
*/
class VersionGuesser
{

View File

@ -95,9 +95,9 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
private $allowSslDowngrade = false;
/** @var ?EventDispatcher */
private $eventDispatcher;
/** @var ?array<string, array<int, array{url: non-empty-string, preferred: bool}>> */
/** @var ?array<string, list<array{url: non-empty-string, preferred: bool}>> */
private $sourceMirrors;
/** @var ?array<int, array{url: non-empty-string, preferred: bool}> */
/** @var ?list<array{url: non-empty-string, preferred: bool}> */
private $distMirrors;
/** @var bool */
private $degradedMode = false;

View File

@ -133,7 +133,7 @@ class CompositeRepository implements RepositoryInterface
$matches[] = $repository->search($query, $mode, $type);
}
return $matches ? array_merge(...$matches) : [];
return \count($matches) > 0 ? array_merge(...$matches) : [];
}
/**

View File

@ -28,7 +28,7 @@ class RepositoryUtils
*
* @template T of PackageInterface
* @param array<T> $packages
* @param array<T> $bucket Do not pass this in, only used to avoid recursion with circular deps
* @param list<T> $bucket Do not pass this in, only used to avoid recursion with circular deps
* @return list<T>
*/
public static function filterRequiredPackages(array $packages, PackageInterface $requirer, array $bucket = []): array

View File

@ -383,7 +383,7 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt
$packageData = $this->preProcess($driver, $data, $identifier);
$package = $this->loader->load($packageData);
if ($this->loader instanceof ValidatingArrayLoader && $this->loader->getWarnings()) {
if ($this->loader instanceof ValidatingArrayLoader && \count($this->loader->getWarnings()) > 0) {
throw new InvalidPackageException($this->loader->getErrors(), $this->loader->getWarnings(), $packageData);
}
$this->addPackage($package);

View File

@ -226,6 +226,9 @@ class Bitbucket
$this->config->getAuthConfigSource()->addConfigSetting('bitbucket-oauth.'.$originUrl, $consumer);
}
/**
* @phpstan-assert-if-true array{access_token: string} $this->token
*/
private function getTokenFromConfig(string $originUrl): bool
{
$authConfig = $this->config->get('bitbucket-oauth');

View File

@ -574,6 +574,7 @@ class Filesystem
// ensure c: is normalized to C:
$prefix = Preg::replaceCallback('{(^|://)[a-z]:$}i', static function (array $m) {
assert(is_string($m[0]));
return strtoupper($m[0]);
}, $prefix);

View File

@ -98,6 +98,8 @@ class Platform
}
return Preg::replaceCallback('#^(\$|(?P<percent>%))(?P<var>\w++)(?(percent)%)(?P<path>.*)#', static function ($matches): string {
assert(is_string($matches['var']));
// Treat HOME as an alias for USERPROFILE on Windows for legacy reasons
if (Platform::isWindows() && $matches['var'] === 'HOME') {
return (Platform::getEnv('HOME') ?: Platform::getEnv('USERPROFILE')) . $matches['path'];

View File

@ -415,6 +415,8 @@ class ProcessExecutor
$commandString = is_string($command) ? $command : implode(' ', array_map(self::class.'::escape', $command));
$safeCommand = Preg::replaceCallback('{://(?P<user>[^:/\s]+):(?P<password>[^@\s/]+)@}i', static function ($m): string {
assert(is_string($m['user']));
// if the username looks like a long (12char+) hex string, or a modern github token (e.g. ghp_xxx) we obfuscate that
if (Preg::isMatch('{^([a-f0-9]{12,}|gh[a-z]_[a-zA-Z0-9_]+)$}', $m['user'])) {
return '://***:***@';

View File

@ -52,7 +52,7 @@ class RemoteFilesystem
private $options = [];
/** @var bool */
private $disableTls = false;
/** @var string[] */
/** @var list<string> */
private $lastHeaders;
/** @var bool */
private $storeAuth = false;
@ -159,7 +159,7 @@ class RemoteFilesystem
/**
* Returns the headers of the last request
*
* @return string[]
* @return list<string>
*/
public function getLastHeaders()
{

View File

@ -110,6 +110,7 @@ class Url
$url = Preg::replace('{([&?]access_token=)[^&]+}', '$1***', $url);
$url = Preg::replaceCallback('{^(?P<prefix>[a-z0-9]+://)?(?P<user>[^:/\s@]+):(?P<password>[^@\s/]+)@}i', static function ($m): string {
assert(is_string($m['user']));
// if the username looks like a long (12char+) hex string, or a modern github token (e.g. ghp_xxx) we obfuscate that
if (Preg::isMatch('{^([a-f0-9]{12,}|gh[a-z]_[a-zA-Z0-9_]+|github_pat_[a-zA-Z0-9_]+)$}', $m['user'])) {
return $m['prefix'].'***:***@';

View File

@ -148,7 +148,7 @@ class PoolBuilderTest extends TestCase
/**
* @param array<int, BasePackage> $packageIds
* @return string[]
* @return list<string|int>
*/
private function getPackageResultSet(Pool $pool, array $packageIds): array
{

View File

@ -32,7 +32,7 @@ class HttpDownloaderMock extends HttpDownloader
*/
private $strict = false;
/**
* @var array{status: int, body: string, headers: array<string>}
* @var array{status: int, body: string, headers: list<string>}
*/
private $defaultHandler = ['status' => 200, 'body' => '', 'headers' => []];
/**
@ -52,9 +52,9 @@ class HttpDownloaderMock extends HttpDownloader
}
/**
* @param array<array{url: non-empty-string, options?: array<mixed>, status?: int, body?: string, headers?: array<string>}> $expectations
* @param array<array{url: non-empty-string, options?: array<mixed>, status?: int, body?: string, headers?: list<string>}> $expectations
* @param bool $strict set to true if you want to provide *all* expected http requests, and not just a subset you are interested in testing
* @param array{status?: int, body?: string, headers?: array<string>} $defaultHandler default URL handler for undefined requests if not in strict mode
* @param array{status?: int, body?: string, headers?: list<string>} $defaultHandler default URL handler for undefined requests if not in strict mode
*/
public function expects(array $expectations, bool $strict = false, array $defaultHandler = ['status' => 200, 'body' => '', 'headers' => []]): void
{
@ -119,7 +119,7 @@ class HttpDownloaderMock extends HttpDownloader
}
/**
* @param string[] $headers
* @param list<string> $headers
* @param non-empty-string $url
*/
private function respond(string $url, int $status, array $headers, string $body): Response

View File

@ -49,6 +49,7 @@ class VersionGuesserTest extends TestCase
$guesser = new VersionGuesser($config, $process, new VersionParser());
$versionArray = $guesser->guessVersion([], 'dummy/path');
self::assertIsArray($versionArray);
$this->assertEquals("dev-".$branch, $versionArray['version']);
$this->assertEquals("dev-".$branch, $versionArray['pretty_version']);
$this->assertEmpty($versionArray['commit']);
@ -72,6 +73,7 @@ class VersionGuesserTest extends TestCase
$guesser = new VersionGuesser($config, $process, new VersionParser());
$versionArray = $guesser->guessVersion([], 'dummy/path');
self::assertIsArray($versionArray);
$this->assertEquals("dev-master", $versionArray['version']);
$this->assertEquals("dev-master", $versionArray['pretty_version']);
$this->assertArrayNotHasKey('feature_version', $versionArray);
@ -98,6 +100,7 @@ class VersionGuesserTest extends TestCase
$guesser = new VersionGuesser($config, $process, new VersionParser());
$versionArray = $guesser->guessVersion(['version' => 'self.version'], 'dummy/path');
self::assertIsArray($versionArray);
$this->assertEquals("dev-current", $versionArray['version']);
$this->assertEquals($anotherCommitHash, $versionArray['commit']);
}
@ -124,8 +127,10 @@ class VersionGuesserTest extends TestCase
$guesser = new VersionGuesser($config, $process, new VersionParser());
$versionArray = $guesser->guessVersion(['version' => 'self.version', 'non-feature-branches' => ['arbitrary']], 'dummy/path');
self::assertIsArray($versionArray);
$this->assertEquals("dev-arbitrary", $versionArray['version']);
$this->assertEquals($anotherCommitHash, $versionArray['commit']);
self::assertArrayHasKey('feature_version', $versionArray);
$this->assertEquals("dev-feature", $versionArray['feature_version']);
$this->assertEquals("dev-feature", $versionArray['feature_pretty_version']);
}
@ -152,8 +157,10 @@ class VersionGuesserTest extends TestCase
$guesser = new VersionGuesser($config, $process, new VersionParser());
$versionArray = $guesser->guessVersion(['version' => 'self.version', 'non-feature-branches' => ['latest-.*']], 'dummy/path');
self::assertIsArray($versionArray);
$this->assertEquals("dev-latest-testing", $versionArray['version']);
$this->assertEquals($anotherCommitHash, $versionArray['commit']);
self::assertArrayHasKey('feature_version', $versionArray);
$this->assertEquals("dev-feature", $versionArray['feature_version']);
$this->assertEquals("dev-feature", $versionArray['feature_pretty_version']);
}
@ -176,6 +183,7 @@ class VersionGuesserTest extends TestCase
$guesser = new VersionGuesser($config, $process, new VersionParser());
$versionArray = $guesser->guessVersion(['version' => 'self.version', 'non-feature-branches' => ['latest-.*']], 'dummy/path');
self::assertIsArray($versionArray);
$this->assertEquals("dev-latest-testing", $versionArray['version']);
$this->assertEquals($commitHash, $versionArray['commit']);
$this->assertArrayNotHasKey('feature_version', $versionArray);
@ -200,6 +208,7 @@ class VersionGuesserTest extends TestCase
$guesser = new VersionGuesser($config, $process, new VersionParser());
$versionData = $guesser->guessVersion([], 'dummy/path');
self::assertIsArray($versionData);
$this->assertEquals("dev-$commitHash", $versionData['version']);
}
@ -221,6 +230,7 @@ class VersionGuesserTest extends TestCase
$guesser = new VersionGuesser($config, $process, new VersionParser());
$versionData = $guesser->guessVersion([], 'dummy/path');
self::assertIsArray($versionData);
$this->assertEquals("dev-$commitHash", $versionData['version']);
}
@ -242,6 +252,7 @@ class VersionGuesserTest extends TestCase
$guesser = new VersionGuesser($config, $process, new VersionParser());
$versionData = $guesser->guessVersion([], 'dummy/path');
self::assertIsArray($versionData);
$this->assertEquals("dev-$commitHash", $versionData['version']);
}
@ -264,6 +275,7 @@ class VersionGuesserTest extends TestCase
$guesser = new VersionGuesser($config, $process, new VersionParser());
$versionData = $guesser->guessVersion([], 'dummy/path');
self::assertIsArray($versionData);
$this->assertEquals("2.0.5.0-alpha2", $versionData['version']);
}
@ -286,6 +298,7 @@ class VersionGuesserTest extends TestCase
$guesser = new VersionGuesser($config, $process, new VersionParser());
$versionData = $guesser->guessVersion([], 'dummy/path');
self::assertIsArray($versionData);
$this->assertEquals('1.0.0.0', $versionData['version']);
$this->assertEquals('1.0.0', $versionData['pretty_version']);
}
@ -305,6 +318,7 @@ class VersionGuesserTest extends TestCase
$guesser = new VersionGuesser($config, $process, new VersionParser());
$versionData = $guesser->guessVersion([], 'dummy/path');
self::assertIsArray($versionData);
$this->assertEquals("dev-foo", $versionData['version']);
}
@ -323,6 +337,7 @@ class VersionGuesserTest extends TestCase
$guesser = new VersionGuesser($config, $process, new VersionParser());
$versionData = $guesser->guessVersion([], 'dummy/path');
self::assertIsArray($versionData);
$this->assertEquals("1.5.x-dev", $versionData['pretty_version']);
$this->assertEquals("1.5.9999999.9999999-dev", $versionData['version']);
}
@ -346,6 +361,7 @@ class VersionGuesserTest extends TestCase
$config->merge(['repositories' => ['packagist' => false]]);
$guesser = new VersionGuesser($config, $process, new VersionParser());
$versionData = $guesser->guessVersion(['version' => 'self.version'], 'dummy/path');
self::assertIsArray($versionData);
$this->assertEquals("1.5.x-dev", $versionData['pretty_version']);
$this->assertEquals("1.5.9999999.9999999-dev", $versionData['version']);
}

View File

@ -94,6 +94,7 @@ class GitHubDriverTest extends TestCase
$this->assertEquals('test_master', $gitHubDriver->getRootIdentifier());
$dist = $gitHubDriver->getDist($sha);
self::assertIsArray($dist);
$this->assertEquals('zip', $dist['type']);
$this->assertEquals('https://api.github.com/repos/composer/packagist/zipball/SOMESHA', $dist['url']);
$this->assertEquals('SOMESHA', $dist['reference']);
@ -136,6 +137,7 @@ class GitHubDriverTest extends TestCase
$this->assertEquals('test_master', $gitHubDriver->getRootIdentifier());
$dist = $gitHubDriver->getDist($sha);
self::assertIsArray($dist);
$this->assertEquals('zip', $dist['type']);
$this->assertEquals('https://api.github.com/repos/composer/packagist/zipball/SOMESHA', $dist['url']);
$this->assertEquals($sha, $dist['reference']);
@ -181,6 +183,7 @@ class GitHubDriverTest extends TestCase
$this->assertEquals('test_master', $gitHubDriver->getRootIdentifier());
$dist = $gitHubDriver->getDist($sha);
self::assertIsArray($dist);
$this->assertEquals('zip', $dist['type']);
$this->assertEquals('https://api.github.com/repos/composer/packagist/zipball/SOMESHA', $dist['url']);
$this->assertEquals($sha, $dist['reference']);
@ -288,6 +291,7 @@ class GitHubDriverTest extends TestCase
$this->assertEquals('test_master', $gitHubDriver->getRootIdentifier());
$dist = $gitHubDriver->getDist($sha);
self::assertIsArray($dist);
$this->assertEquals('zip', $dist['type']);
$this->assertEquals('https://api.github.com/repos/composer/packagist/zipball/SOMESHA', $dist['url']);
$this->assertEquals($sha, $dist['reference']);

View File

@ -331,6 +331,7 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase
{
if (Platform::isWindows()) {
$cmd = Preg::replaceCallback("/('[^']*')/", static function ($m) {
assert(is_string($m[1]));
// Double-quotes are used only when needed
$char = (strpbrk($m[1], " \t^&|<>()") !== false || $m[1] === "''") ? '"' : '';

View File

@ -73,6 +73,7 @@ class TlsHelperTest extends TestCase
// @phpstan-ignore-next-line
$names = TlsHelper::getCertificateNames($certificate);
self::assertIsArray($names);
$this->assertSame('example.net', $names['cn']);
$this->assertSame([
'example.com',