Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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<T>` 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@3d714eb
- Loading branch information