diff --git a/composer.json b/composer.json index 6e378f4..1d54697 100644 --- a/composer.json +++ b/composer.json @@ -7,7 +7,7 @@ ], "require": { "php": "^7.4 || ^8.0", - "phpstan/phpstan": "^2.1.15" + "phpstan/phpstan": "^2.1.34" }, "require-dev": { "php-parallel-lint/php-parallel-lint": "^1.2", diff --git a/tests/Rules/Deprecations/FetchingDeprecatedConstRuleTest.php b/tests/Rules/Deprecations/FetchingDeprecatedConstRuleTest.php index 1428ec2..c09f8f6 100644 --- a/tests/Rules/Deprecations/FetchingDeprecatedConstRuleTest.php +++ b/tests/Rules/Deprecations/FetchingDeprecatedConstRuleTest.php @@ -5,6 +5,7 @@ use PHPStan\Rules\Rule; use PHPStan\Testing\RuleTestCase; use function defined; +use const PHP_VERSION_ID; /** * @extends RuleTestCase @@ -59,4 +60,32 @@ public function testFetchingDeprecatedConst(): void ); } + public function testEstrictWithVersionGuard(): void + { + $errors = [ + [ + 'Use of constant E_STRICT is deprecated.', + 7, + ], + ]; + if (PHP_VERSION_ID >= 80400) { + $errors = [ + [ + 'Use of constant E_STRICT is deprecated.', + 7, + ], + [ + 'Use of constant E_STRICT is deprecated.', + 18, + ], + ]; + } + + require_once __DIR__ . '/data/bug-162.php'; + $this->analyse( + [__DIR__ . '/data/bug-162.php'], + $errors, + ); + } + } diff --git a/tests/Rules/Deprecations/data/bug-162.php b/tests/Rules/Deprecations/data/bug-162.php new file mode 100644 index 0000000..2bc64e5 --- /dev/null +++ b/tests/Rules/Deprecations/data/bug-162.php @@ -0,0 +1,20 @@ += 80400) { + if (E_STRICT === $errno) { + + } + } + + if (PHP_VERSION_ID < 80400) { + if (E_STRICT === $errno) { + + } + } + + if (E_STRICT === $errno ) { + } +}