1
0
Fork 0

Update phpstan & baseline (2158, 104)

pull/10669/head
Jordi Boggiano 2022-03-29 14:03:05 +02:00
parent 854aab5f03
commit 6bd75d5738
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
6 changed files with 52 additions and 95 deletions

47
composer.lock generated
View File

@ -1824,20 +1824,20 @@
"packages-dev": [
{
"name": "phpstan/phpstan",
"version": "1.4.10",
"version": "1.5.2",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan.git",
"reference": "898c479c39caa727bedf4311dd294a8f4e250e72"
"reference": "f32e95f571c9587b4e14be05253ae56fedd00b2c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/898c479c39caa727bedf4311dd294a8f4e250e72",
"reference": "898c479c39caa727bedf4311dd294a8f4e250e72",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/f32e95f571c9587b4e14be05253ae56fedd00b2c",
"reference": "f32e95f571c9587b4e14be05253ae56fedd00b2c",
"shasum": ""
},
"require": {
"php": "^7.1|^8.0"
"php": "^7.2|^8.0"
},
"conflict": {
"phpstan/phpstan-shim": "*"
@ -1859,7 +1859,7 @@
"description": "PHPStan - PHP Static Analysis Tool",
"support": {
"issues": "https://github.com/phpstan/phpstan/issues",
"source": "https://github.com/phpstan/phpstan/tree/1.4.10"
"source": "https://github.com/phpstan/phpstan/tree/1.5.2"
},
"funding": [
{
@ -1879,7 +1879,7 @@
"type": "tidelift"
}
],
"time": "2022-03-14T10:25:45+00:00"
"time": "2022-03-29T07:34:36+00:00"
},
{
"name": "phpstan/phpstan-deprecation-rules",
@ -1933,21 +1933,21 @@
},
{
"name": "phpstan/phpstan-phpunit",
"version": "1.0.0",
"version": "1.1.0",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan-phpunit.git",
"reference": "9eb88c9f689003a8a2a5ae9e010338ee94dc39b3"
"reference": "09133ce914f1388a8bb8c7f8573aaa3723cff52a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/9eb88c9f689003a8a2a5ae9e010338ee94dc39b3",
"reference": "9eb88c9f689003a8a2a5ae9e010338ee94dc39b3",
"url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/09133ce914f1388a8bb8c7f8573aaa3723cff52a",
"reference": "09133ce914f1388a8bb8c7f8573aaa3723cff52a",
"shasum": ""
},
"require": {
"php": "^7.1 || ^8.0",
"phpstan/phpstan": "^1.0"
"php": "^7.2 || ^8.0",
"phpstan/phpstan": "^1.5.0"
},
"conflict": {
"phpunit/phpunit": "<7.0"
@ -1960,9 +1960,6 @@
},
"type": "phpstan-extension",
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
},
"phpstan": {
"includes": [
"extension.neon",
@ -1982,9 +1979,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.0.0"
"source": "https://github.com/phpstan/phpstan-phpunit/tree/1.1.0"
},
"time": "2021-10-14T08:03:54+00:00"
"time": "2022-03-28T09:20:49+00:00"
},
{
"name": "phpstan/phpstan-strict-rules",
@ -2039,16 +2036,16 @@
},
{
"name": "phpstan/phpstan-symfony",
"version": "1.1.7",
"version": "1.1.8",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan-symfony.git",
"reference": "8ef80f5c4f70ebd31a55647bc082ea9df4bf0132"
"reference": "4bdffcf1033b6c60662a28419d0192e0dda5684f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan-symfony/zipball/8ef80f5c4f70ebd31a55647bc082ea9df4bf0132",
"reference": "8ef80f5c4f70ebd31a55647bc082ea9df4bf0132",
"url": "https://api.github.com/repos/phpstan/phpstan-symfony/zipball/4bdffcf1033b6c60662a28419d0192e0dda5684f",
"reference": "4bdffcf1033b6c60662a28419d0192e0dda5684f",
"shasum": ""
},
"require": {
@ -2107,9 +2104,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.1.7"
"source": "https://github.com/phpstan/phpstan-symfony/tree/1.1.8"
},
"time": "2022-02-25T19:36:13+00:00"
"time": "2022-03-24T07:56:03+00:00"
},
{
"name": "symfony/phpunit-bridge",
@ -2207,5 +2204,5 @@
"platform-overrides": {
"php": "7.2.5"
},
"plugin-api-version": "2.2.0"
"plugin-api-version": "2.3.0"
}

View File

@ -780,11 +780,6 @@ parameters:
count: 1
path: ../src/Composer/Command/RemoveCommand.php
-
message: "#^Only booleans are allowed in &&, array\\<string\\> given on the right side\\.$#"
count: 2
path: ../src/Composer/Command/RemoveCommand.php
-
message: "#^Only booleans are allowed in an if condition, Composer\\\\Composer\\|null given\\.$#"
count: 1
@ -800,11 +795,6 @@ parameters:
count: 3
path: ../src/Composer/Command/RemoveCommand.php
-
message: "#^Parameter \\#2 \\$array of static method Composer\\\\Pcre\\\\Preg\\:\\:grep\\(\\) expects array\\<string\\>, array\\<int, int\\|string\\> given\\.$#"
count: 2
path: ../src/Composer/Command/RemoveCommand.php
-
message: "#^Cannot call method getRepoName\\(\\) on Composer\\\\Repository\\\\RepositoryInterface\\|null\\.$#"
count: 4
@ -1815,16 +1805,6 @@ parameters:
count: 1
path: ../src/Composer/DependencyResolver/Request.php
-
message: "#^Binary operation \"\\.\" between array\\{package\\: Composer\\\\Package\\\\BasePackage\\}\\|array\\{packageName\\: string, constraint\\: Composer\\\\Semver\\\\Constraint\\\\ConstraintInterface\\}\\|Composer\\\\Package\\\\BasePackage\\|Composer\\\\Package\\\\Link\\|int\\|string and ' and thus cannot…' results in an error\\.$#"
count: 1
path: ../src/Composer/DependencyResolver/Rule.php
-
message: "#^Binary operation \"\\.\" between literal\\-string&non\\-empty\\-string and array\\{package\\: Composer\\\\Package\\\\BasePackage\\}\\|array\\{packageName\\: string, constraint\\: Composer\\\\Semver\\\\Constraint\\\\ConstraintInterface\\}\\|Composer\\\\Package\\\\BasePackage\\|Composer\\\\Package\\\\Link\\|int\\|string results in an error\\.$#"
count: 1
path: ../src/Composer/DependencyResolver/Rule.php
-
message: "#^Cannot access offset 'constraint' on array\\{package\\: Composer\\\\Package\\\\BasePackage\\}\\|array\\{packageName\\: string, constraint\\: Composer\\\\Semver\\\\Constraint\\\\ConstraintInterface\\}\\|Composer\\\\Package\\\\BasePackage\\|Composer\\\\Package\\\\Link\\|int\\|string\\.$#"
count: 2
@ -1905,11 +1885,6 @@ parameters:
count: 1
path: ../src/Composer/DependencyResolver/Rule.php
-
message: "#^Possibly invalid array key type array\\<string, Composer\\\\Package\\\\BasePackage\\|Composer\\\\Semver\\\\Constraint\\\\ConstraintInterface\\|string\\>\\|Composer\\\\Package\\\\BasePackage\\|Composer\\\\Package\\\\Link\\|int\\|string\\.$#"
count: 2
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
@ -5168,26 +5143,11 @@ parameters:
count: 2
path: ../src/Composer/Util/Http/CurlDownloader.php
-
message: "#^Only booleans are allowed in &&, Composer\\\\Util\\\\Http\\\\CurlResponse\\|null given on the right side\\.$#"
count: 1
path: ../src/Composer/Util/Http/CurlDownloader.php
-
message: "#^Only booleans are allowed in &&, array\\<int, string\\>\\|null given on the right side\\.$#"
count: 1
path: ../src/Composer/Util/Http/CurlDownloader.php
-
message: "#^Only booleans are allowed in &&, int given on the right side\\.$#"
count: 2
path: ../src/Composer/Util/Http/CurlDownloader.php
-
message: "#^Only booleans are allowed in &&, mixed given on the right side\\.$#"
count: 1
path: ../src/Composer/Util/Http/CurlDownloader.php
-
message: "#^Only booleans are allowed in a negated boolean, resource\\|false given\\.$#"
count: 1
@ -5830,7 +5790,7 @@ parameters:
-
message: "#^Parameter \\#1 \\$str of static method Composer\\\\Util\\\\Platform\\:\\:strlen\\(\\) expects string, string\\|false given\\.$#"
count: 5
count: 3
path: ../src/Composer/Util/RemoteFilesystem.php
-
@ -6696,11 +6656,6 @@ parameters:
count: 1
path: ../tests/Composer/Test/Repository/PathRepositoryTest.php
-
message: "#^Parameter \\#2 \\.\\.\\.\\$args of function array_merge expects array, array\\<string, array\\<int, array\\|string\\>\\>\\|false given\\.$#"
count: 1
path: ../tests/Composer/Test/Repository/PlatformRepositoryTest.php
-
message: "#^Call to method PHPUnit\\\\Framework\\\\Assert\\:\\:assertInstanceOf\\(\\) with 'Composer\\\\\\\\Repository…' and Composer\\\\Repository\\\\FilterRepository will always evaluate to true\\.$#"
count: 1

View File

@ -134,6 +134,7 @@ EOT
$file = Factory::getComposerFile();
$jsonFile = new JsonFile($file);
/** @var array{require?: array<string, string>, require-dev?: array<string, string>} $composer */
$composer = $jsonFile->read();
$composerBackup = file_get_contents($jsonFile->getPath());
@ -176,7 +177,7 @@ EOT
}
}
}
} elseif (isset($composer[$type]) && $matches = Preg::grep(BasePackage::packageNameToRegexp($package), array_keys($composer[$type]))) {
} elseif (isset($composer[$type]) && count($matches = Preg::grep(BasePackage::packageNameToRegexp($package), array_keys($composer[$type]))) > 0) {
foreach ($matches as $matchedPackage) {
if ($dryRun) {
$toRemove[$type][] = $matchedPackage;
@ -184,7 +185,7 @@ EOT
$json->removeLink($type, $matchedPackage);
}
}
} elseif (isset($composer[$altType]) && $matches = Preg::grep(BasePackage::packageNameToRegexp($package), array_keys($composer[$altType]))) {
} elseif (isset($composer[$altType]) && count($matches = Preg::grep(BasePackage::packageNameToRegexp($package), array_keys($composer[$altType]))) > 0) {
foreach ($matches as $matchedPackage) {
$io->writeError('<warning>' . $matchedPackage . ' could not be found in ' . $type . ' but it is present in ' . $altType . '</warning>');
if ($io->isInteractive()) {

View File

@ -373,6 +373,7 @@ abstract class Rule
$package = $pool->literalToPackage($literal);
$packageNames[$package->getName()] = true;
}
/** @var string $replacedName */
$replacedName = $this->reasonData;
if (count($packageNames) > 1) {

View File

@ -333,6 +333,9 @@ class CurlDownloader
}
$progress = curl_getinfo($curlHandle);
if (false === $progress) {
throw new \RuntimeException('Failed getting info from curl handle '.$i.' ('.$this->jobs[$i]['url'].')');
}
$job = $this->jobs[$i];
unset($this->jobs[$i]);
$error = curl_error($curlHandle);
@ -364,7 +367,7 @@ class CurlDownloader
continue;
}
if ($errno === 28 /* CURLE_OPERATION_TIMEDOUT */ && isset($progress['namelookup_time']) && $progress['namelookup_time'] == 0 && !$timeoutWarning) {
if ($errno === 28 /* CURLE_OPERATION_TIMEDOUT */ && PHP_VERSION_ID >= 70300 && $progress['namelookup_time'] == 0 && !$timeoutWarning) {
$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>');
}
@ -443,14 +446,14 @@ class CurlDownloader
call_user_func($job['resolve'], $response);
}
} catch (\Exception $e) {
if ($e instanceof TransportException && $headers) {
$e->setHeaders($headers);
$e->setStatusCode($statusCode);
}
if ($e instanceof TransportException && $response) {
$e->setResponse($response->getBody());
}
if ($e instanceof TransportException && $progress) {
if ($e instanceof TransportException) {
if (null !== $headers) {
$e->setHeaders($headers);
$e->setStatusCode($statusCode);
}
if (null !== $response) {
$e->setResponse($response->getBody());
}
$e->setResponseInfo($progress);
}

View File

@ -1078,7 +1078,7 @@ Linked Version => 1.2.11',
*
* @param string|string[] $extensions
* @param string|null $info
* @param array<string,string|false> $expectations
* @param array<string,string|false|array{string|false, 1?: string[], 2?: string[]}> $expectations array of packageName => expected version (or false if expected to be msising), or packageName => array(expected version, expected replaced names, expected provided names)
* @param list<mixed> $functions
* @param list<mixed> $constants
* @param list<mixed> $classDefinitions
@ -1153,10 +1153,6 @@ Linked Version => 1.2.11',
$platformRepository = new PlatformRepository(array(), array(), $runtime);
$expectations = array_map(function ($expectation): array {
return array_replace(array(null, array(), array()), (array) $expectation);
}, $expectations);
$libraries = array_map(
function ($package): string {
return $package['name'];
@ -1168,17 +1164,21 @@ Linked Version => 1.2.11',
}
)
);
$expectedLibraries = array_merge(array_keys(array_filter($expectations, function ($expectation): bool {
return $expectation[0] !== false;
})));
$expectedLibraries = array_keys(array_filter($expectations, function ($expectation): bool {
return $expectation !== false;
}));
self::assertCount(count(array_filter($expectedLibraries)), $libraries, sprintf('Expected: %s, got %s', var_export($expectedLibraries, true), var_export($libraries, true)));
$expectations = array_merge($expectations, array_combine(array_map(function ($extension): string {
return 'ext-'.$extension;
}, $extensions), array_fill(0, count($extensions), array($extensionVersion, array(), array()))));
foreach ($extensions as $extension) {
$expectations['ext-'.$extension] = $extensionVersion;
}
foreach ($expectations as $packageName => $expectation) {
list($expectedVersion, $expectedReplaces, $expectedProvides) = $expectation;
foreach ($expectations as $expectedLibOrExt => $expectation) {
$packageName = $expectedLibOrExt;
if (!is_array($expectation)) {
$expectation = [$expectation, [], []];
}
list($expectedVersion, $expectedReplaces, $expectedProvides) = array_pad($expectation, 3, []);
$package = $platformRepository->findPackage($packageName, '*');
if ($expectedVersion === false) {