From 045fa8415ad4dc81ce8b8a5495b57d6a3e3cd7be Mon Sep 17 00:00:00 2001 From: anomiex Date: Tue, 16 Apr 2024 17:01:47 +0000 Subject: [PATCH] phan: Add stubs for PHPUnit 9.6 (#36881) PHPUnit 9.6 has three major issues when it comes to analysis with Phan: * It uses `@psalm`-prefixed phpdocs various places, which Phan doesn't understand. This most obviously shows up with mock objects where it only knows that they're `MockObject` and not also the class being mocked. * It has the parameter type incorrectly declared for `->with()`. * Phan loses the generic typing for methods that `@return $this` (it wants `@return $this` to tell it the generic still applies). We can work around all of these issues by generating stubs for PHPUnit, then munging them to rewrite the `@psalm-` docs to `@phan-` and to fix the incorrect docs. All this is done by the same script from #36803 that we already have set up to auto-update WooCommerce stubs. Then we may as well fix the new issues this turns up: * Don't try to php-lint stub files. They don't need to be valid PHP as long as Phan is happy with them. * For `yoast/phpunit-polyfills`, prefer the empty versions of the traits so we get the PHPUnit versions of things like `assertIsArray()` where PHPUnit already gives us `@phan-assert array $actual`. * Remove lots of Phan suppressions added in previous PRs with comments about the PHPUnit issues above. * Suppress lots of `PhanPluginUnreachableCode` now that Phan knows that methods like `->markTestSkipped()` never return. * Suppress some PhanEmptyFQSENInClasslike warnings issued due to a Phan bug when intersection types are passed in callables. * packages/jetpack-mu-wpcom is missing a dep on automattic/jetpack-status which was being hacked around in a test (and presumably only working in production because Jetpack is bringing in the package). * And some other miscellaneous things. Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/8709448100 Upstream-Ref: Automattic/jetpack@3d714eb394f4ad67d5f1630560463a6f75839b26 --- composer.json | 2 +- composer.lock | 10 +++++----- .../automattic/jetpack-device-detection/composer.json | 2 +- vendor/composer/installed.json | 4 ++-- vendor/composer/installed.php | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/composer.json b/composer.json index a9891d5b..fee17ccf 100644 --- a/composer.json +++ b/composer.json @@ -8,7 +8,7 @@ }, "require-dev": { "yoast/phpunit-polyfills": "1.1.0", - "automattic/jetpack-changelogger": "^4.2.1" + "automattic/jetpack-changelogger": "^4.2.2-alpha" }, "autoload": { "classmap": [ diff --git a/composer.lock b/composer.lock index 168505b1..67fa7ee9 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": "cccba972c97e20a908e08ce20e863e2f", + "content-hash": "c5d8937e55382734e60f13264f13c344", "packages": [ { "name": "automattic/jetpack-device-detection", @@ -12,13 +12,13 @@ "dist": { "type": "path", "url": "/tmp/jetpack-build/Automattic/jetpack-device-detection", - "reference": "2fea361c1c62203aeb07748bdd6780bfcdee1578" + "reference": "b7ab04ebbb478bd0d60ef69c0485a4f591d4334b" }, "require": { "php": ">=7.0" }, "require-dev": { - "automattic/jetpack-changelogger": "^4.2.1", + "automattic/jetpack-changelogger": "^4.2.2-alpha", "yoast/phpunit-polyfills": "1.1.0" }, "suggest": { @@ -60,11 +60,11 @@ "packages-dev": [ { "name": "automattic/jetpack-changelogger", - "version": "4.2.1", + "version": "4.2.2-alpha.1713286100", "dist": { "type": "path", "url": "/tmp/jetpack-build/Automattic/jetpack-changelogger", - "reference": "d8a86d0d9540f196ea697403390ad2e8f68b194c" + "reference": "c0693fdba03f883b458963de500eb6d4252361b6" }, "require": { "php": ">=7.0", diff --git a/vendor/automattic/jetpack-device-detection/composer.json b/vendor/automattic/jetpack-device-detection/composer.json index 07b422e6..9c6c03cb 100644 --- a/vendor/automattic/jetpack-device-detection/composer.json +++ b/vendor/automattic/jetpack-device-detection/composer.json @@ -8,7 +8,7 @@ }, "require-dev": { "yoast/phpunit-polyfills": "1.1.0", - "automattic/jetpack-changelogger": "^4.2.1" + "automattic/jetpack-changelogger": "^4.2.2-alpha" }, "suggest": { "automattic/jetpack-autoloader": "Allow for better interoperability with other plugins that use this package." diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 6b5c836a..d962edb0 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -7,13 +7,13 @@ "dist": { "type": "path", "url": "/tmp/jetpack-build/Automattic/jetpack-device-detection", - "reference": "2fea361c1c62203aeb07748bdd6780bfcdee1578" + "reference": "b7ab04ebbb478bd0d60ef69c0485a4f591d4334b" }, "require": { "php": ">=7.0" }, "require-dev": { - "automattic/jetpack-changelogger": "^4.2.1", + "automattic/jetpack-changelogger": "^4.2.2-alpha", "yoast/phpunit-polyfills": "1.1.0" }, "suggest": { diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index 9999e79d..06116f0a 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -13,7 +13,7 @@ 'automattic/jetpack-device-detection' => array( 'pretty_version' => '2.1.3', 'version' => '2.1.3.0', - 'reference' => '2fea361c1c62203aeb07748bdd6780bfcdee1578', + 'reference' => 'b7ab04ebbb478bd0d60ef69c0485a4f591d4334b', 'type' => 'jetpack-library', 'install_path' => __DIR__ . '/../automattic/jetpack-device-detection', 'aliases' => array(),