From 5bb30ca170e9f494446c473a1552db80b8ff8f59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Mirtes?= Date: Wed, 22 May 2024 09:09:04 +0200 Subject: [PATCH] Update PHPStan (#11976) * Update PHPStan * Update inline ignores to `@phpstan-ignore` with error identifier --- composer.json | 10 +-- composer.lock | 69 +++++++++---------- src/Composer/Command/SelfUpdateCommand.php | 2 +- src/Composer/Console/Input/InputArgument.php | 2 +- src/Composer/Console/Input/InputOption.php | 2 +- src/Composer/Downloader/ZipDownloader.php | 2 +- src/Composer/Installer.php | 2 +- .../PHPStan/ConfigReturnTypeExtension.php | 4 +- src/Composer/Plugin/PostFileDownloadEvent.php | 2 +- .../Repository/ComposerRepository.php | 2 +- src/Composer/Util/Http/CurlDownloader.php | 2 +- src/Composer/Util/Http/Response.php | 4 +- tests/Composer/Test/AllFunctionalTest.php | 2 +- tests/Composer/Test/ConfigTest.php | 2 +- .../Test/DependencyResolver/RuleSetTest.php | 2 +- ...reNothingPlatformRequirementFilterTest.php | 4 +- tests/Composer/Test/IO/NullIOTest.php | 2 +- tests/Composer/Test/InstalledVersionsTest.php | 2 +- tests/Composer/Test/InstallerTest.php | 2 +- .../Composer/Test/Json/JsonFormatterTest.php | 4 +- .../Composer/Test/Mock/HttpDownloaderMock.php | 2 +- tests/Composer/Test/Mock/IOMock.php | 2 +- .../Test/Mock/ProcessExecutorMock.php | 2 +- .../Test/Package/Dumper/ArrayDumperTest.php | 2 +- .../Test/Plugin/PluginInstallerTest.php | 18 ++--- .../Fixtures/installed_relative.php | 10 +-- tests/Composer/Test/Script/EventTest.php | 2 +- tests/Composer/Test/Util/ErrorHandlerTest.php | 4 +- tests/Composer/Test/Util/TlsHelperTest.php | 4 +- 29 files changed, 84 insertions(+), 85 deletions(-) diff --git a/composer.json b/composer.json index 2cbcfa73d..865413970 100644 --- a/composer.json +++ b/composer.json @@ -46,11 +46,11 @@ }, "require-dev": { "symfony/phpunit-bridge": "^6.4.1 || ^7.0.1", - "phpstan/phpstan": "^1.9.3", - "phpstan/phpstan-phpunit": "^1.0", - "phpstan/phpstan-deprecation-rules": "^1", - "phpstan/phpstan-strict-rules": "^1", - "phpstan/phpstan-symfony": "^1.2.10" + "phpstan/phpstan": "^1.11.0", + "phpstan/phpstan-phpunit": "^1.4.0", + "phpstan/phpstan-deprecation-rules": "^1.2.0", + "phpstan/phpstan-strict-rules": "^1.6.0", + "phpstan/phpstan-symfony": "^1.4.0" }, "suggest": { "ext-openssl": "Enabling the openssl extension allows you to access https URLs for repositories and packages", diff --git a/composer.lock b/composer.lock index 63f0fbabd..0abf3ae26 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "bbb9ffc97dcec54f38fdc5b4bf9a287d", + "content-hash": "213c5ab8912ca04b1f7a77c008875ccc", "packages": [ { "name": "composer/ca-bundle", @@ -2015,16 +2015,16 @@ "packages-dev": [ { "name": "phpstan/phpstan", - "version": "1.10.67", + "version": "1.11.0", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "16ddbe776f10da6a95ebd25de7c1dbed397dc493" + "reference": "666cb1703742cea9cc80fee631f0940e1592fa6e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/16ddbe776f10da6a95ebd25de7c1dbed397dc493", - "reference": "16ddbe776f10da6a95ebd25de7c1dbed397dc493", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/666cb1703742cea9cc80fee631f0940e1592fa6e", + "reference": "666cb1703742cea9cc80fee631f0940e1592fa6e", "shasum": "" }, "require": { @@ -2069,29 +2069,28 @@ "type": "github" } ], - "time": "2024-04-16T07:22:02+00:00" + "time": "2024-05-13T06:02:22+00:00" }, { "name": "phpstan/phpstan-deprecation-rules", - "version": "1.1.4", + "version": "1.2.0", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan-deprecation-rules.git", - "reference": "089d8a8258ed0aeefdc7b68b6c3d25572ebfdbaa" + "reference": "fa8cce7720fa782899a0aa97b6a41225d1bb7b26" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan-deprecation-rules/zipball/089d8a8258ed0aeefdc7b68b6c3d25572ebfdbaa", - "reference": "089d8a8258ed0aeefdc7b68b6c3d25572ebfdbaa", + "url": "https://api.github.com/repos/phpstan/phpstan-deprecation-rules/zipball/fa8cce7720fa782899a0aa97b6a41225d1bb7b26", + "reference": "fa8cce7720fa782899a0aa97b6a41225d1bb7b26", "shasum": "" }, "require": { "php": "^7.2 || ^8.0", - "phpstan/phpstan": "^1.10.3" + "phpstan/phpstan": "^1.11" }, "require-dev": { "php-parallel-lint/php-parallel-lint": "^1.2", - "phpstan/phpstan-php-parser": "^1.1", "phpstan/phpstan-phpunit": "^1.0", "phpunit/phpunit": "^9.5" }, @@ -2115,27 +2114,27 @@ "description": "PHPStan rules for detecting usage of deprecated classes, methods, properties, constants and traits.", "support": { "issues": "https://github.com/phpstan/phpstan-deprecation-rules/issues", - "source": "https://github.com/phpstan/phpstan-deprecation-rules/tree/1.1.4" + "source": "https://github.com/phpstan/phpstan-deprecation-rules/tree/1.2.0" }, - "time": "2023-08-05T09:02:04+00:00" + "time": "2024-04-20T06:39:48+00:00" }, { "name": "phpstan/phpstan-phpunit", - "version": "1.3.16", + "version": "1.4.0", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan-phpunit.git", - "reference": "d5242a59d035e46774f2e634b374bc39ff62cb95" + "reference": "f3ea021866f4263f07ca3636bf22c64be9610c11" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/d5242a59d035e46774f2e634b374bc39ff62cb95", - "reference": "d5242a59d035e46774f2e634b374bc39ff62cb95", + "url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/f3ea021866f4263f07ca3636bf22c64be9610c11", + "reference": "f3ea021866f4263f07ca3636bf22c64be9610c11", "shasum": "" }, "require": { "php": "^7.2 || ^8.0", - "phpstan/phpstan": "^1.10" + "phpstan/phpstan": "^1.11" }, "conflict": { "phpunit/phpunit": "<7.0" @@ -2167,27 +2166,27 @@ "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.3.16" + "source": "https://github.com/phpstan/phpstan-phpunit/tree/1.4.0" }, - "time": "2024-02-23T09:51:20+00:00" + "time": "2024-04-20T06:39:00+00:00" }, { "name": "phpstan/phpstan-strict-rules", - "version": "1.5.5", + "version": "1.6.0", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan-strict-rules.git", - "reference": "2e193a07651a6f4be3baa44ddb21d822681f5918" + "reference": "363f921dd8441777d4fc137deb99beb486c77df1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan-strict-rules/zipball/2e193a07651a6f4be3baa44ddb21d822681f5918", - "reference": "2e193a07651a6f4be3baa44ddb21d822681f5918", + "url": "https://api.github.com/repos/phpstan/phpstan-strict-rules/zipball/363f921dd8441777d4fc137deb99beb486c77df1", + "reference": "363f921dd8441777d4fc137deb99beb486c77df1", "shasum": "" }, "require": { "php": "^7.2 || ^8.0", - "phpstan/phpstan": "^1.10.60" + "phpstan/phpstan": "^1.11" }, "require-dev": { "nikic/php-parser": "^4.13.0", @@ -2216,28 +2215,28 @@ "description": "Extra strict and opinionated rules for PHPStan", "support": { "issues": "https://github.com/phpstan/phpstan-strict-rules/issues", - "source": "https://github.com/phpstan/phpstan-strict-rules/tree/1.5.5" + "source": "https://github.com/phpstan/phpstan-strict-rules/tree/1.6.0" }, - "time": "2024-04-19T15:12:26+00:00" + "time": "2024-04-20T06:37:51+00:00" }, { "name": "phpstan/phpstan-symfony", - "version": "1.3.12", + "version": "1.4.0", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan-symfony.git", - "reference": "f4b9407fa3203aebafd422ae8f0eb1ef94659a80" + "reference": "51183fefbaf4713aa81eddbd273dc59dd5e5ff71" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan-symfony/zipball/f4b9407fa3203aebafd422ae8f0eb1ef94659a80", - "reference": "f4b9407fa3203aebafd422ae8f0eb1ef94659a80", + "url": "https://api.github.com/repos/phpstan/phpstan-symfony/zipball/51183fefbaf4713aa81eddbd273dc59dd5e5ff71", + "reference": "51183fefbaf4713aa81eddbd273dc59dd5e5ff71", "shasum": "" }, "require": { "ext-simplexml": "*", "php": "^7.2 || ^8.0", - "phpstan/phpstan": "^1.10.62" + "phpstan/phpstan": "^1.11" }, "conflict": { "symfony/framework-bundle": "<3.0" @@ -2288,9 +2287,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.3.12" + "source": "https://github.com/phpstan/phpstan-symfony/tree/1.4.0" }, - "time": "2024-04-14T13:30:23+00:00" + "time": "2024-04-20T06:38:35+00:00" }, { "name": "symfony/phpunit-bridge", diff --git a/src/Composer/Command/SelfUpdateCommand.php b/src/Composer/Command/SelfUpdateCommand.php index 26d9f7546..1a8797a5b 100644 --- a/src/Composer/Command/SelfUpdateCommand.php +++ b/src/Composer/Command/SelfUpdateCommand.php @@ -329,7 +329,7 @@ TAGSPUBKEY // PHP 8 automatically frees the key instance and deprecates the function if (PHP_VERSION_ID < 80000) { - // @phpstan-ignore-next-line + // @phpstan-ignore function.deprecated openssl_free_key($pubkeyid); } diff --git a/src/Composer/Console/Input/InputArgument.php b/src/Composer/Console/Input/InputArgument.php index b6d064fc8..a64724d6b 100644 --- a/src/Composer/Console/Input/InputArgument.php +++ b/src/Composer/Console/Input/InputArgument.php @@ -59,7 +59,7 @@ class InputArgument extends BaseInputArgument public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void { $values = $this->suggestedValues; - if ($values instanceof \Closure && !\is_array($values = $values($input, $suggestions))) { // @phpstan-ignore-line + if ($values instanceof \Closure && !\is_array($values = $values($input, $suggestions))) { // @phpstan-ignore function.impossibleType throw new LogicException(sprintf('Closure for option "%s" must return an array. Got "%s".', $this->getName(), get_debug_type($values))); } if ([] !== $values) { diff --git a/src/Composer/Console/Input/InputOption.php b/src/Composer/Console/Input/InputOption.php index 75bfe90d9..c742daee7 100644 --- a/src/Composer/Console/Input/InputOption.php +++ b/src/Composer/Console/Input/InputOption.php @@ -62,7 +62,7 @@ class InputOption extends BaseInputOption public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void { $values = $this->suggestedValues; - if ($values instanceof \Closure && !\is_array($values = $values($input, $suggestions))) { // @phpstan-ignore-line + if ($values instanceof \Closure && !\is_array($values = $values($input, $suggestions))) { // @phpstan-ignore function.impossibleType throw new LogicException(sprintf('Closure for argument "%s" must return an array. Got "%s".', $this->getName(), get_debug_type($values))); } if ([] !== $values) { diff --git a/src/Composer/Downloader/ZipDownloader.php b/src/Composer/Downloader/ZipDownloader.php index 9d0f35353..cbd7d0452 100644 --- a/src/Composer/Downloader/ZipDownloader.php +++ b/src/Composer/Downloader/ZipDownloader.php @@ -35,7 +35,7 @@ class ZipDownloader extends ArchiveDownloader private static $isWindows; /** @var ZipArchive|null */ - private $zipArchiveObject; // @phpstan-ignore-line helper property that is set via reflection for testing purposes + private $zipArchiveObject; // @phpstan-ignore property.onlyRead (helper property that is set via reflection for testing purposes) /** * @inheritDoc diff --git a/src/Composer/Installer.php b/src/Composer/Installer.php index 5f07b0e17..856d441e0 100644 --- a/src/Composer/Installer.php +++ b/src/Composer/Installer.php @@ -539,7 +539,7 @@ class Installer } // exists as of composer/semver 3.3.0 - if (method_exists('Composer\Semver\CompilingMatcher', 'clear')) { // @phpstan-ignore-line + if (method_exists('Composer\Semver\CompilingMatcher', 'clear')) { // @phpstan-ignore function.alreadyNarrowedType \Composer\Semver\CompilingMatcher::clear(); } diff --git a/src/Composer/PHPStan/ConfigReturnTypeExtension.php b/src/Composer/PHPStan/ConfigReturnTypeExtension.php index e7ff6e52e..756ad24b5 100644 --- a/src/Composer/PHPStan/ConfigReturnTypeExtension.php +++ b/src/Composer/PHPStan/ConfigReturnTypeExtension.php @@ -72,11 +72,11 @@ final class ConfigReturnTypeExtension implements DynamicMethodReturnTypeExtensio } $keyType = $scope->getType($args[0]->value); - if (method_exists($keyType, 'getConstantStrings')) { // @phpstan-ignore-line - depending on PHPStan version, this method will always exist, or not. + if (method_exists($keyType, 'getConstantStrings')) { // @phpstan-ignore function.alreadyNarrowedType (- depending on PHPStan version, this method will always exist, or not.) $strings = $keyType->getConstantStrings(); } else { // for compat with old phpstan versions, we use a deprecated phpstan method. - $strings = TypeUtils::getConstantStrings($keyType); // @phpstan-ignore-line ignore deprecation + $strings = TypeUtils::getConstantStrings($keyType); // @phpstan-ignore staticMethod.deprecated (ignore deprecation) } if ($strings !== []) { $types = []; diff --git a/src/Composer/Plugin/PostFileDownloadEvent.php b/src/Composer/Plugin/PostFileDownloadEvent.php index e78991646..a8d9a025f 100644 --- a/src/Composer/Plugin/PostFileDownloadEvent.php +++ b/src/Composer/Plugin/PostFileDownloadEvent.php @@ -59,7 +59,7 @@ class PostFileDownloadEvent extends Event */ public function __construct(string $name, ?string $fileName, ?string $checksum, string $url, string $type, $context = null) { - /** @phpstan-ignore-next-line */ + /** @phpstan-ignore instanceof.alwaysFalse, booleanAnd.alwaysFalse */ if ($context === null && $type instanceof PackageInterface) { $context = $type; $type = 'package'; diff --git a/src/Composer/Repository/ComposerRepository.php b/src/Composer/Repository/ComposerRepository.php index ec244b129..47874f829 100644 --- a/src/Composer/Repository/ComposerRepository.php +++ b/src/Composer/Repository/ComposerRepository.php @@ -432,7 +432,7 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito $uniques = []; foreach ($names as $name) { - // @phpstan-ignore-next-line + // @phpstan-ignore argument.type $uniques[substr($name, 0, strpos($name, '/'))] = true; } diff --git a/src/Composer/Util/Http/CurlDownloader.php b/src/Composer/Util/Http/CurlDownloader.php index 827d2a369..d3e68f838 100644 --- a/src/Composer/Util/Http/CurlDownloader.php +++ b/src/Composer/Util/Http/CurlDownloader.php @@ -176,7 +176,7 @@ class CurlDownloader } $errorMessage = ''; - // @phpstan-ignore-next-line + // @phpstan-ignore argument.type set_error_handler(static function ($code, $msg) use (&$errorMessage): void { if ($errorMessage) { $errorMessage .= "\n"; diff --git a/src/Composer/Util/Http/Response.php b/src/Composer/Util/Http/Response.php index 5e5d18a2e..0821e054a 100644 --- a/src/Composer/Util/Http/Response.php +++ b/src/Composer/Util/Http/Response.php @@ -36,7 +36,7 @@ class Response */ public function __construct(array $request, ?int $code, array $headers, ?string $body) { - if (!isset($request['url'])) { // @phpstan-ignore-line + if (!isset($request['url'])) { throw new \LogicException('url key missing from request array'); } $this->request = $request; @@ -101,7 +101,7 @@ class Response */ public function collect(): void { - /** @phpstan-ignore-next-line */ + /** @phpstan-ignore assign.propertyType, assign.propertyType, assign.propertyType */ $this->request = $this->code = $this->headers = $this->body = null; } diff --git a/tests/Composer/Test/AllFunctionalTest.php b/tests/Composer/Test/AllFunctionalTest.php index 7d6834431..7fb22795d 100644 --- a/tests/Composer/Test/AllFunctionalTest.php +++ b/tests/Composer/Test/AllFunctionalTest.php @@ -248,7 +248,7 @@ class AllFunctionalTest extends TestCase throw new \RuntimeException('The test file must have a section named "EXPECT", "EXPECT-REGEX", or "EXPECT-REGEXES".'); } - return $data; // @phpstan-ignore-line + return $data; // @phpstan-ignore return.type } private function cleanOutput(string $output): string diff --git a/tests/Composer/Test/ConfigTest.php b/tests/Composer/Test/ConfigTest.php index 8a169b745..08cdfac36 100644 --- a/tests/Composer/Test/ConfigTest.php +++ b/tests/Composer/Test/ConfigTest.php @@ -420,7 +420,7 @@ class ConfigTest extends TestCase ]; foreach ($keys as $key) { $value = $config->get($key); - $this->assertIsArray($value); // @phpstan-ignore-line - PHPStan knows that its an array for all given keys + $this->assertIsArray($value); // @phpstan-ignore staticMethod.dynamicCall (- PHPStan knows that its an array for all given keys) $this->assertCount(0, $value); } } diff --git a/tests/Composer/Test/DependencyResolver/RuleSetTest.php b/tests/Composer/Test/DependencyResolver/RuleSetTest.php index ee84c8770..cc8e154c9 100644 --- a/tests/Composer/Test/DependencyResolver/RuleSetTest.php +++ b/tests/Composer/Test/DependencyResolver/RuleSetTest.php @@ -68,7 +68,7 @@ class RuleSetTest extends TestCase $ruleSet = new RuleSet; self::expectException('OutOfBoundsException'); - // @phpstan-ignore-next-line + // @phpstan-ignore argument.type $ruleSet->add(new GenericRule([], Rule::RULE_ROOT_REQUIRE, ['packageName' => '', 'constraint' => new MatchAllConstraint]), 7); } diff --git a/tests/Composer/Test/Filter/PlatformRequirementFilter/IgnoreNothingPlatformRequirementFilterTest.php b/tests/Composer/Test/Filter/PlatformRequirementFilter/IgnoreNothingPlatformRequirementFilterTest.php index 70c3fabd2..36fb69ba5 100644 --- a/tests/Composer/Test/Filter/PlatformRequirementFilter/IgnoreNothingPlatformRequirementFilterTest.php +++ b/tests/Composer/Test/Filter/PlatformRequirementFilter/IgnoreNothingPlatformRequirementFilterTest.php @@ -24,8 +24,8 @@ final class IgnoreNothingPlatformRequirementFilterTest extends TestCase { $platformRequirementFilter = new IgnoreNothingPlatformRequirementFilter(); - $this->assertFalse($platformRequirementFilter->isIgnored($req)); // @phpstan-ignore-line - $this->assertFalse($platformRequirementFilter->isUpperBoundIgnored($req)); // @phpstan-ignore-line + $this->assertFalse($platformRequirementFilter->isIgnored($req)); // @phpstan-ignore staticMethod.dynamicCall + $this->assertFalse($platformRequirementFilter->isUpperBoundIgnored($req)); // @phpstan-ignore staticMethod.dynamicCall } /** diff --git a/tests/Composer/Test/IO/NullIOTest.php b/tests/Composer/Test/IO/NullIOTest.php index 9aa6bc6a9..6bc3aa043 100644 --- a/tests/Composer/Test/IO/NullIOTest.php +++ b/tests/Composer/Test/IO/NullIOTest.php @@ -42,7 +42,7 @@ class NullIOTest extends TestCase { $io = new NullIO(); - $this->assertIsArray($io->getAuthentications()); // @phpstan-ignore-line + $this->assertIsArray($io->getAuthentications()); // @phpstan-ignore staticMethod.dynamicCall $this->assertEmpty($io->getAuthentications()); $this->assertEquals(['username' => null, 'password' => null], $io->getAuthentication('foo')); } diff --git a/tests/Composer/Test/InstalledVersionsTest.php b/tests/Composer/Test/InstalledVersionsTest.php index 3fa9b1bc1..7e34f7e37 100644 --- a/tests/Composer/Test/InstalledVersionsTest.php +++ b/tests/Composer/Test/InstalledVersionsTest.php @@ -41,7 +41,7 @@ class InstalledVersionsTest extends TestCase $prop = new \ReflectionProperty('Composer\Autoload\ClassLoader', 'registeredLoaders'); $prop->setAccessible(true); $prop->setValue(null, self::$previousRegisteredLoaders); - InstalledVersions::reload(null); // @phpstan-ignore-line + InstalledVersions::reload(null); // @phpstan-ignore argument.type } public function setUp(): void diff --git a/tests/Composer/Test/InstallerTest.php b/tests/Composer/Test/InstallerTest.php index 858d88e7c..490eac996 100644 --- a/tests/Composer/Test/InstallerTest.php +++ b/tests/Composer/Test/InstallerTest.php @@ -279,7 +279,7 @@ class InstallerTest extends TestCase { if ($condition) { eval('$res = '.$condition.';'); - if (!$res) { // @phpstan-ignore-line + if (!$res) { // @phpstan-ignore variable.undefined $this->markTestSkipped($condition); } } diff --git a/tests/Composer/Test/Json/JsonFormatterTest.php b/tests/Composer/Test/Json/JsonFormatterTest.php index 88f76dfec..9bc38c673 100644 --- a/tests/Composer/Test/Json/JsonFormatterTest.php +++ b/tests/Composer/Test/Json/JsonFormatterTest.php @@ -29,7 +29,7 @@ class JsonFormatterTest extends TestCase $backslash = chr(92); $data = '"' . $backslash . $backslash . $backslash . 'u0119"'; $expected = '"' . $backslash . $backslash . 'ę"'; - /** @phpstan-ignore-next-line */ + /** @phpstan-ignore staticMethod.dynamicCall, staticMethod.deprecatedClass */ $this->assertEquals($expected, JsonFormatter::format($data, true, true)); } @@ -44,7 +44,7 @@ class JsonFormatterTest extends TestCase } $escaped = '"\ud83d\ude00"'; - /** @phpstan-ignore-next-line */ + /** @phpstan-ignore staticMethod.dynamicCall, staticMethod.deprecatedClass */ $this->assertEquals($escaped, JsonFormatter::format($escaped, true, true)); } } diff --git a/tests/Composer/Test/Mock/HttpDownloaderMock.php b/tests/Composer/Test/Mock/HttpDownloaderMock.php index 0005a5d87..a0325118c 100644 --- a/tests/Composer/Test/Mock/HttpDownloaderMock.php +++ b/tests/Composer/Test/Mock/HttpDownloaderMock.php @@ -90,7 +90,7 @@ class HttpDownloaderMock extends HttpDownloader } // dummy assertion to ensure the test is not marked as having no assertions - Assert::assertTrue(true); // @phpstan-ignore-line + Assert::assertTrue(true); // @phpstan-ignore staticMethod.alreadyNarrowedType } public function get($fileUrl, $options = []): Response diff --git a/tests/Composer/Test/Mock/IOMock.php b/tests/Composer/Test/Mock/IOMock.php index 13a87d1b5..42ff1b258 100644 --- a/tests/Composer/Test/Mock/IOMock.php +++ b/tests/Composer/Test/Mock/IOMock.php @@ -142,7 +142,7 @@ class IOMock extends BufferIO } // dummy assertion to ensure the test is not marked as having no assertions - Assert::assertTrue(true); // @phpstan-ignore-line + Assert::assertTrue(true); // @phpstan-ignore staticMethod.alreadyNarrowedType } /** diff --git a/tests/Composer/Test/Mock/ProcessExecutorMock.php b/tests/Composer/Test/Mock/ProcessExecutorMock.php index 9f633a626..c90b6bc1d 100644 --- a/tests/Composer/Test/Mock/ProcessExecutorMock.php +++ b/tests/Composer/Test/Mock/ProcessExecutorMock.php @@ -100,7 +100,7 @@ class ProcessExecutorMock extends ProcessExecutor } // dummy assertion to ensure the test is not marked as having no assertions - Assert::assertTrue(true); // @phpstan-ignore-line + Assert::assertTrue(true); // @phpstan-ignore staticMethod.alreadyNarrowedType } public function execute($command, &$output = null, ?string $cwd = null): int diff --git a/tests/Composer/Test/Package/Dumper/ArrayDumperTest.php b/tests/Composer/Test/Package/Dumper/ArrayDumperTest.php index a7738a469..ca885243a 100644 --- a/tests/Composer/Test/Package/Dumper/ArrayDumperTest.php +++ b/tests/Composer/Test/Package/Dumper/ArrayDumperTest.php @@ -81,7 +81,7 @@ class ArrayDumperTest extends TestCase { $package = self::getRootPackage(); - // @phpstan-ignore-next-line + // @phpstan-ignore method.dynamicName, ternary.shortNotAllowed $package->{'set'.ucfirst($method ?: $key)}($value); $config = $this->dumper->dump($package); diff --git a/tests/Composer/Test/Plugin/PluginInstallerTest.php b/tests/Composer/Test/Plugin/PluginInstallerTest.php index a5eb07d3e..ecaa615a2 100644 --- a/tests/Composer/Test/Plugin/PluginInstallerTest.php +++ b/tests/Composer/Test/Plugin/PluginInstallerTest.php @@ -160,7 +160,7 @@ class PluginInstallerTest extends TestCase $installer->install($this->repository, $this->packages[0]); $plugins = $this->pm->getPlugins(); - $this->assertEquals('installer-v1', $plugins[0]->version); // @phpstan-ignore-line + $this->assertEquals('installer-v1', $plugins[0]->version); // @phpstan-ignore staticMethod.dynamicCall, property.notFound $this->assertEquals( 'activate v1'.PHP_EOL, $this->io->getOutput() @@ -186,7 +186,7 @@ class PluginInstallerTest extends TestCase 'activate v1'.PHP_EOL, $this->io->getOutput() ); - $this->assertEquals('installer-v1', $plugins[0]->version); // @phpstan-ignore-line + $this->assertEquals('installer-v1', $plugins[0]->version); // @phpstan-ignore staticMethod.dynamicCall, property.notFound } public function testInstallMultiplePlugins(): void @@ -201,10 +201,10 @@ class PluginInstallerTest extends TestCase $installer->install($this->repository, $this->packages[3]); $plugins = $this->pm->getPlugins(); - $this->assertEquals('plugin1', $plugins[0]->name); // @phpstan-ignore-line - $this->assertEquals('installer-v4', $plugins[0]->version); // @phpstan-ignore-line - $this->assertEquals('plugin2', $plugins[1]->name); // @phpstan-ignore-line - $this->assertEquals('installer-v4', $plugins[1]->version); // @phpstan-ignore-line + $this->assertEquals('plugin1', $plugins[0]->name); // @phpstan-ignore staticMethod.dynamicCall, property.notFound + $this->assertEquals('installer-v4', $plugins[0]->version); // @phpstan-ignore staticMethod.dynamicCall, property.notFound + $this->assertEquals('plugin2', $plugins[1]->name); // @phpstan-ignore staticMethod.dynamicCall, property.notFound + $this->assertEquals('installer-v4', $plugins[1]->version); // @phpstan-ignore staticMethod.dynamicCall, property.notFound $this->assertEquals('activate v4-plugin1'.PHP_EOL.'activate v4-plugin2'.PHP_EOL, $this->io->getOutput()); } @@ -225,7 +225,7 @@ class PluginInstallerTest extends TestCase $plugins = $this->pm->getPlugins(); $this->assertCount(1, $plugins); - $this->assertEquals('installer-v2', $plugins[1]->version); // @phpstan-ignore-line + $this->assertEquals('installer-v2', $plugins[1]->version); // @phpstan-ignore staticMethod.dynamicCall, property.notFound $this->assertEquals('activate v1'.PHP_EOL.'deactivate v1'.PHP_EOL.'activate v2'.PHP_EOL, $this->io->getOutput()); } @@ -265,7 +265,7 @@ class PluginInstallerTest extends TestCase $installer->update($this->repository, $this->packages[1], $this->packages[2]); $plugins = $this->pm->getPlugins(); - $this->assertEquals('installer-v3', $plugins[1]->version); // @phpstan-ignore-line + $this->assertEquals('installer-v3', $plugins[1]->version); // @phpstan-ignore staticMethod.dynamicCall, property.notFound $this->assertEquals('activate v2'.PHP_EOL.'deactivate v2'.PHP_EOL.'activate v3'.PHP_EOL, $this->io->getOutput()); } @@ -283,7 +283,7 @@ class PluginInstallerTest extends TestCase $plugins = $this->pm->getPlugins(); $this->assertCount(1, $plugins); - $this->assertEquals('installer-v1', $plugins[0]->version); // @phpstan-ignore-line + $this->assertEquals('installer-v1', $plugins[0]->version); // @phpstan-ignore staticMethod.dynamicCall, property.notFound $this->assertEquals('activate v1'.PHP_EOL, $this->io->getOutput()); } diff --git a/tests/Composer/Test/Repository/Fixtures/installed_relative.php b/tests/Composer/Test/Repository/Fixtures/installed_relative.php index 443e460c1..93dc5d890 100644 --- a/tests/Composer/Test/Repository/Fixtures/installed_relative.php +++ b/tests/Composer/Test/Repository/Fixtures/installed_relative.php @@ -5,7 +5,7 @@ 'version' => 'dev-master', 'reference' => 'sourceref-by-default', 'type' => 'library', - // @phpstan-ignore-next-line + // @phpstan-ignore variable.undefined 'install_path' => $dir . '/./', 'aliases' => array( '1.10.x-dev', @@ -18,7 +18,7 @@ 'version' => 'dev-master', 'reference' => 'sourceref-by-default', 'type' => 'library', - // @phpstan-ignore-next-line + // @phpstan-ignore variable.undefined 'install_path' => $dir . '/./', 'aliases' => array( '1.10.x-dev', @@ -30,7 +30,7 @@ 'version' => '1.1.0.0', 'reference' => 'distref-as-no-source', 'type' => 'library', - // @phpstan-ignore-next-line + // @phpstan-ignore variable.undefined 'install_path' => $dir . '/vendor/a/provider', 'aliases' => array(), 'dev_requirement' => false, @@ -40,7 +40,7 @@ 'version' => '1.2.0.0', 'reference' => 'distref-as-installed-from-dist', 'type' => 'library', - // @phpstan-ignore-next-line + // @phpstan-ignore variable.undefined 'install_path' => $dir . '/vendor/a/provider2', 'aliases' => array( '1.4', @@ -52,7 +52,7 @@ 'version' => '2.2.0.0', 'reference' => null, 'type' => 'library', - // @phpstan-ignore-next-line + // @phpstan-ignore variable.undefined 'install_path' => $dir . '/vendor/b/replacer', 'aliases' => array(), 'dev_requirement' => false, diff --git a/tests/Composer/Test/Script/EventTest.php b/tests/Composer/Test/Script/EventTest.php index c085ad110..1647f7169 100644 --- a/tests/Composer/Test/Script/EventTest.php +++ b/tests/Composer/Test/Script/EventTest.php @@ -35,7 +35,7 @@ class EventTest extends TestCase $scriptEvent->setOriginatingEvent($originatingEvent); - // @phpstan-ignore-next-line + // @phpstan-ignore staticMethod.dynamicCall $this->assertSame( $originatingEvent, $scriptEvent->getOriginatingEvent(), diff --git a/tests/Composer/Test/Util/ErrorHandlerTest.php b/tests/Composer/Test/Util/ErrorHandlerTest.php index a177f6fe0..29f10463f 100644 --- a/tests/Composer/Test/Util/ErrorHandlerTest.php +++ b/tests/Composer/Test/Util/ErrorHandlerTest.php @@ -45,7 +45,7 @@ class ErrorHandlerTest extends TestCase } $array = ['foo' => 'bar']; - // @phpstan-ignore-next-line + // @phpstan-ignore offsetAccess.notFound, expr.resultUnused $array['baz']; } @@ -62,7 +62,7 @@ class ErrorHandlerTest extends TestCase self::expectExceptionMessage('array_merge'); } - // @phpstan-ignore-next-line + // @phpstan-ignore function.resultUnused, argument.type array_merge([], 'string'); } diff --git a/tests/Composer/Test/Util/TlsHelperTest.php b/tests/Composer/Test/Util/TlsHelperTest.php index bda7f53ce..58144a425 100644 --- a/tests/Composer/Test/Util/TlsHelperTest.php +++ b/tests/Composer/Test/Util/TlsHelperTest.php @@ -27,7 +27,7 @@ class TlsHelperTest extends TestCase $certificate['subject']['commonName'] = $expectedCn = array_shift($certNames); $certificate['extensions']['subjectAltName'] = $certNames ? 'DNS:'.implode(',DNS:', $certNames) : ''; - // @phpstan-ignore-next-line + // @phpstan-ignore staticMethod.deprecatedClass $result = TlsHelper::checkCertificateHost($certificate, $hostname, $foundCn); if (true === $expectedResult) { @@ -70,7 +70,7 @@ class TlsHelperTest extends TestCase $certificate['subject']['commonName'] = 'example.net'; $certificate['extensions']['subjectAltName'] = 'DNS: example.com, IP: 127.0.0.1, DNS: getcomposer.org, Junk: blah, DNS: composer.example.org'; - // @phpstan-ignore-next-line + // @phpstan-ignore staticMethod.deprecatedClass $names = TlsHelper::getCertificateNames($certificate); self::assertIsArray($names);