Skip to content

Commit 853a27b

Browse files
committed
Prevent reporting property.inInterface error when PHP version is 8.4 or later
1 parent c0bfae6 commit 853a27b

File tree

2 files changed

+23
-11
lines changed

2 files changed

+23
-11
lines changed

src/Rules/Properties/PropertiesInInterfaceRule.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
*/
1414
final class PropertiesInInterfaceRule implements Rule
1515
{
16+
private const PHP_8_4_VERSION_ID = 80400;
1617

1718
public function getNodeType(): string
1819
{
@@ -25,6 +26,10 @@ public function processNode(Node $node, Scope $scope): array
2526
return [];
2627
}
2728

29+
if (PHP_VERSION_ID >= self::PHP_8_4_VERSION_ID) {
30+
return [];
31+
}
32+
2833
return [
2934
RuleErrorBuilder::message('Interfaces may not include properties.')
3035
->nonIgnorable()

tests/PHPStan/Rules/Properties/PropertiesInInterfaceRuleTest.php

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace PHPStan\Rules\Properties;
44

5+
use PHPStan\Analyser\Error;
56
use PHPStan\Rules\Rule;
67
use PHPStan\Testing\RuleTestCase;
78

@@ -10,6 +11,7 @@
1011
*/
1112
class PropertiesInInterfaceRuleTest extends RuleTestCase
1213
{
14+
private const PHP_8_4_VERSION_ID = 80400;
1315

1416
protected function getRule(): Rule
1517
{
@@ -18,16 +20,21 @@ protected function getRule(): Rule
1820

1921
public function testRule(): void
2022
{
21-
$this->analyse([__DIR__ . '/data/properties-in-interface.php'], [
22-
[
23-
'Interfaces may not include properties.',
24-
7,
25-
],
26-
[
27-
'Interfaces may not include properties.',
28-
9,
29-
],
30-
]);
31-
}
23+
if (PHP_VERSION_ID < self::PHP_8_4_VERSION_ID) {
24+
$this->analyse([__DIR__ . '/data/properties-in-interface.php'], [
25+
[
26+
'Interfaces may not include properties.',
27+
7,
28+
],
29+
[
30+
'Interfaces may not include properties.',
31+
9,
32+
],
33+
]);
34+
35+
return;
36+
}
3237

38+
$this->analyse([__DIR__ . '/data/properties-in-interface.php'], []);
39+
}
3340
}

0 commit comments

Comments
 (0)