Skip to content

Commit 6712f9b

Browse files
committed
Require PHP 8.2 for the trait constant fixture and cover a PHP version range spanning 8.6
1 parent b6bb114 commit 6712f9b

4 files changed

Lines changed: 65 additions & 1 deletion

File tree

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace PHPStan\Rules\Constants;
4+
5+
use PHPStan\Rules\Rule;
6+
use PHPStan\Testing\RuleTestCase;
7+
use PHPUnit\Framework\Attributes\RequiresPhp;
8+
9+
/** @extends RuleTestCase<OverridingConstantRule> */
10+
class OverridingConstantRuleConfigPhpTest extends RuleTestCase
11+
{
12+
13+
protected function getRule(): Rule
14+
{
15+
return new OverridingConstantRule(
16+
true,
17+
new OverrideAttributeOnConstantCheck(
18+
checkMissingOverrideConstantAttribute: null,
19+
checkMissingOverrideMethodAttribute: true,
20+
),
21+
);
22+
}
23+
24+
#[RequiresPhp('>= 8.2.0')]
25+
public function testMissingOverrideAttributeNotCheckedOnPhpVersionRangeSpanning86(): void
26+
{
27+
$this->analyse([__DIR__ . '/data/constant-override-attr.php'], [
28+
[
29+
'Constant ConstantOverrideAttr\Bar::PRIVATE_FROM_PARENT has #[\Override] attribute but does not override any constant.',
30+
28,
31+
],
32+
[
33+
'Constant ConstantOverrideAttr\Bar::NOT_OVERRIDING has #[\Override] attribute but does not override any constant.',
34+
31,
35+
],
36+
[
37+
'Constant ConstantOverrideAttr\Baz::ALSO_NOT_OVERRIDING has #[\Override] attribute but does not override any constant.',
38+
41,
39+
],
40+
[
41+
'Constant ConstantOverrideAttr\BarInterface::NOT_OVERRIDING has #[\Override] attribute but does not override any constant.',
42+
50,
43+
],
44+
[
45+
'Constant ConstantOverrideAttr\UsesTraitWithoutParent::FROM_PARENT has #[\Override] attribute but does not override any constant.',
46+
56,
47+
],
48+
]);
49+
}
50+
51+
public static function getAdditionalConfigFiles(): array
52+
{
53+
return [
54+
__DIR__ . '/data/constant-override-attr-php-version.neon',
55+
];
56+
}
57+
58+
}

‎tests/PHPStan/Rules/Constants/OverridingConstantRuleTest.php‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ public function testNativeTypes(): void
122122
]);
123123
}
124124

125+
#[RequiresPhp('>= 8.2.0')]
125126
public function testOverrideAttribute(): void
126127
{
127128
$this->checkMissingOverrideConstantAttribute = true;
@@ -153,6 +154,7 @@ public function testOverrideAttribute(): void
153154
]);
154155
}
155156

157+
#[RequiresPhp('>= 8.2.0')]
156158
public function testMissingOverrideAttributeNotCheckedByDefaultBeforePhp86(): void
157159
{
158160
$this->checkMissingOverrideConstantAttribute = null;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
parameters:
2+
phpVersion:
3+
min: 80500
4+
max: 80600

‎tests/PHPStan/Rules/Constants/data/constant-override-attr.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php // lint >= 8.0
1+
<?php // lint >= 8.2
22

33
namespace ConstantOverrideAttr;
44

0 commit comments

Comments
 (0)