Skip to content

Commit 72c4a36

Browse files
authored
[TASK] Allow PHP 8.6 with PHPStan extension (#1648)
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 MyIntervals/PHP-CSS-Parser#1627. Ref: phpstan/phpstan#15127
1 parent ad69f89 commit 72c4a36

1 file changed

Lines changed: 16 additions & 8 deletions

File tree

tests/Unit/PhpStan/IgnoreBooleanAlwaysImpossibleAssertTest.php

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use PHPStan\Analyser\IgnoreErrorExtension;
88
use PHPStan\Rules\Comparison\ImpossibleCheckTypeFunctionCallRule;
99
use PHPStan\Rules\Rule;
10+
use PHPUnit\Framework\Error\Deprecated;
1011

1112
/**
1213
* This covers `function.alreadyNarrowedType` error handling in the `IgnoreBooleanAlways` PHPStan extension class.
@@ -39,15 +40,22 @@ public function warningIsRetainedForPointlessAssert(): void
3940
self::markTestSkipped('This is testing the testers, and only needs to run whenever possible.');
4041
}
4142

42-
// Second argument is array of expected warnings.
43-
$this->analyse(
44-
[self::FIXTURES_DIR . 'alwaystrue-pointlessassert.php'],
45-
[
43+
// TODO: remove try/catch block when PHPStan is fixed.
44+
try {
45+
// Second argument is array of expected warnings.
46+
$this->analyse(
47+
[self::FIXTURES_DIR . 'alwaystrue-pointlessassert.php'],
4648
[
47-
'Call to function is_int() with int will always evaluate to true.',
48-
7,
49+
[
50+
'Call to function is_int() with int will always evaluate to true.',
51+
7,
52+
],
4953
],
50-
],
51-
);
54+
);
55+
} catch (Deprecated $e) {
56+
self::markTestSkipped(
57+
'PHPStan has a dependency on an Hoa library that triggers a deprecation warning with PHP 8.6.'
58+
);
59+
}
5260
}
5361
}

0 commit comments

Comments
 (0)