From 1265f382fb3236b374f2f1b764c509adf169dadb Mon Sep 17 00:00:00 2001 From: Jake Hotson Date: Sat, 29 Aug 2026 18:29:07 +0100 Subject: [PATCH] [TASK] Allow PHP 8.6 with PHPStan extension PHPStan has a dependency (Hoa) that triggers a deprecation warning in PHP 8.6. PHPUnit fails tests if any warnings or notices are triggered. This change is a temporary patch so that PHP 8.6 can be supported, until a permanent fix in PHPStan is released, and mirrors https://github.com/MyIntervals/PHP-CSS-Parser/pull/1627. Ref: https://github.com/phpstan/phpstan/issues/15127 --- ...gnoreBooleanAlwaysImpossibleAssertTest.php | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/tests/Unit/PhpStan/IgnoreBooleanAlwaysImpossibleAssertTest.php b/tests/Unit/PhpStan/IgnoreBooleanAlwaysImpossibleAssertTest.php index 4cd70711..31183b8a 100644 --- a/tests/Unit/PhpStan/IgnoreBooleanAlwaysImpossibleAssertTest.php +++ b/tests/Unit/PhpStan/IgnoreBooleanAlwaysImpossibleAssertTest.php @@ -7,6 +7,7 @@ use PHPStan\Analyser\IgnoreErrorExtension; use PHPStan\Rules\Comparison\ImpossibleCheckTypeFunctionCallRule; use PHPStan\Rules\Rule; +use PHPUnit\Framework\Error\Deprecated; /** * This covers `function.alreadyNarrowedType` error handling in the `IgnoreBooleanAlways` PHPStan extension class. @@ -39,15 +40,22 @@ public function warningIsRetainedForPointlessAssert(): void self::markTestSkipped('This is testing the testers, and only needs to run whenever possible.'); } - // Second argument is array of expected warnings. - $this->analyse( - [self::FIXTURES_DIR . 'alwaystrue-pointlessassert.php'], - [ + // TODO: remove try/catch block when PHPStan is fixed. + try { + // Second argument is array of expected warnings. + $this->analyse( + [self::FIXTURES_DIR . 'alwaystrue-pointlessassert.php'], [ - 'Call to function is_int() with int will always evaluate to true.', - 7, + [ + 'Call to function is_int() with int will always evaluate to true.', + 7, + ], ], - ], - ); + ); + } catch (Deprecated $e) { + self::markTestSkipped( + 'PHPStan has a dependency on an Hoa library that triggers a deprecation warning with PHP 8.6.' + ); + } } }