Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
29 changes: 29 additions & 0 deletions tests/Rules/Deprecations/FetchingDeprecatedConstRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use PHPStan\Rules\Rule;
use PHPStan\Testing\RuleTestCase;
use function defined;
use const PHP_VERSION_ID;

/**
* @extends RuleTestCase<FetchingDeprecatedConstRule>
Expand Down Expand Up @@ -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,
);
}

}
20 changes: 20 additions & 0 deletions tests/Rules/Deprecations/data/bug-162.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace Bug162;

function foo(int $errno):void {
if (PHP_VERSION_ID >= 80400) {
if (E_STRICT === $errno) {

}
}

if (PHP_VERSION_ID < 80400) {
if (E_STRICT === $errno) {

}
}

if (E_STRICT === $errno ) {
}
}
Loading