From 2d92e2119ac6ae71ed9d231629c5d7faa0ff6ddb Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Tue, 7 Dec 2021 09:33:45 +0100 Subject: [PATCH] Add deprecations checks --- .github/workflows/phpstan.yml | 2 +- composer.json | 2 +- phpstan/baseline.neon | 43 +++++++++++++++++++++-------------- phpstan/config.neon | 4 ++++ 4 files changed, 32 insertions(+), 19 deletions(-) diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml index 3614de87f..40877dc5a 100644 --- a/.github/workflows/phpstan.yml +++ b/.github/workflows/phpstan.yml @@ -51,7 +51,7 @@ jobs: - name: "Install PHPStan" # Locked to phpunit 7.5 here as newer ones have void return types which break inheritance - run: "bin/composer require --dev phpstan/phpstan:^1.0 phpstan/phpstan-phpunit:^1.0 phpunit/phpunit:^7.5.20 --with-all-dependencies ${{ env.COMPOSER_FLAGS }}" + run: "bin/composer require --dev phpstan/phpstan:^1.0 phpstan/phpstan-phpunit:^1.0 phpstan/phpstan-deprecation-rules:^1 phpstan/phpstan-strict-rules:^1 phpunit/phpunit:^7.5.20 --with-all-dependencies ${{ env.COMPOSER_FLAGS }}" - name: "Run PHPStan" run: "vendor/bin/phpstan analyse --configuration=phpstan/config.neon" diff --git a/composer.json b/composer.json index 83ab7ae55..fe8751c71 100644 --- a/composer.json +++ b/composer.json @@ -82,7 +82,7 @@ "phpstan-setup": [ "@composer config platform --unset", "@composer update", - "@composer require --dev phpstan/phpstan:^1.0 phpstan/phpstan-phpunit:^1.0 phpunit/phpunit:^7.5.20 --with-all-dependencies", + "@composer require --dev phpstan/phpstan:^1.0 phpstan/phpstan-phpunit:^1.0 phpstan/phpstan-deprecation-rules:^1 phpstan/phpstan-strict-rules:^1 phpunit/phpunit:^7.5.20 --with-all-dependencies", "git checkout composer.json composer.lock" ], "phpstan": "@php vendor/bin/phpstan analyse --configuration=phpstan/config.neon" diff --git a/phpstan/baseline.neon b/phpstan/baseline.neon index d26311763..d73e319a4 100644 --- a/phpstan/baseline.neon +++ b/phpstan/baseline.neon @@ -1,22 +1,31 @@ parameters: - ignoreErrors: + ignoreErrors: + - + message: "#^Parameter \\#1 \\$autoload_function of function spl_autoload_register expects callable\\(string\\)\\: void, array\\{\\$this\\(Composer\\\\Autoload\\\\ClassLoader\\), 'loadClass'\\} given\\.$#" + count: 1 + path: ../src/Composer/Autoload/ClassLoader.php + # reported as https://github.com/phpstan/phpstan/issues/6008 - - - message: "#^Offset 'curl_id' on array{curl_id:#" - count: 1 - path: ../src/Composer/Util/HttpDownloader.php + - + message: "#^Offset 'curl_id' on array\\{curl_id\\: int, exception\\: Composer\\\\Downloader\\\\TransportException, id\\: int, origin\\: string, reject\\: mixed, request\\: array\\{url\\: string, options\\?\\: array, copyTo\\?\\: string\\|null\\}, resolve\\: mixed, response\\: Composer\\\\Util\\\\Http\\\\Response, \\.\\.\\.\\} in isset\\(\\) always exists and is not nullable\\.$#" + count: 1 + path: ../src/Composer/Util/HttpDownloader.php - - - message: "#^Parameter \\#1 \\$autoload_function of function spl_autoload_register expects callable\\(string\\)\\: void, array\\{\\$this\\(Composer\\\\Autoload\\\\ClassLoader\\), 'loadClass'\\} given\\.$#" - count: 1 - path: ../src/Composer/Autoload/ClassLoader.php + - + message: + """ + #^Call to deprecated method getRawData\\(\\) of class Composer\\\\InstalledVersions\\: + Use getAllRawData\\(\\) instead which returns all datasets for all autoloaders present in the process\\. getRawData only returns the first dataset loaded, which may not be what you expect\\.$# + """ + count: 1 + path: ../tests/Composer/Test/InstalledVersionsTest.php - - - message: "#^Parameter \\#2 \\$capabilityClassName of method Composer\\\\Plugin\\\\PluginManager\\:\\:getPluginCapability\\(\\) expects class\\-string\\, string given\\.$#" - count: 2 - path: ../tests/Composer/Test/Plugin/PluginInstallerTest.php + - + message: "#^Parameter \\#2 \\$capabilityClassName of method Composer\\\\Plugin\\\\PluginManager\\:\\:getPluginCapability\\(\\) expects class\\-string\\, string given\\.$#" + count: 2 + path: ../tests/Composer/Test/Plugin/PluginInstallerTest.php - - - message: "#^Unable to resolve the template type CapabilityClass in call to method Composer\\\\Plugin\\\\PluginManager::getPluginCapability\\(\\)$#" - count: 2 - path: ../tests/Composer/Test/Plugin/PluginInstallerTest.php + - + message: "#^Unable to resolve the template type CapabilityClass in call to method Composer\\\\Plugin\\\\PluginManager\\:\\:getPluginCapability\\(\\)$#" + count: 2 + path: ../tests/Composer/Test/Plugin/PluginInstallerTest.php diff --git a/phpstan/config.neon b/phpstan/config.neon index d36542cda..b2e206e43 100644 --- a/phpstan/config.neon +++ b/phpstan/config.neon @@ -1,5 +1,7 @@ includes: - ../vendor/phpstan/phpstan-phpunit/extension.neon + - ../vendor/phpstan/phpstan-deprecation-rules/rules.neon +# - ../vendor/phpstan/phpstan-strict-rules/rules.neon - ./baseline.neon parameters: @@ -10,6 +12,8 @@ parameters: - '../tests/Composer/Test/Autoload/Fixtures/*' - '../tests/Composer/Test/Plugin/Fixtures/*' - '../tests/Composer/Test/PolyfillTestCase.php' + # TODO Remove in 2.3 + - '../src/Composer/Console/HtmlOutputFormatter.php' reportUnmatchedIgnoredErrors: false