Skip to content

Commit e6e84f7

Browse files
committed
improve error messages
1 parent b7bd2e4 commit e6e84f7

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

src/Rules/Properties/PropertiesInInterfaceRule.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function processNode(Node $node, Scope $scope): array
3232

3333
if (!$this->phpVersion->supportsPropertyHooks()) {
3434
return [
35-
RuleErrorBuilder::message('Interfaces cannot include properties.')
35+
RuleErrorBuilder::message('Interfaces can include properties only on PHP 8.4 and later.')
3636
->nonIgnorable()
3737
->identifier('property.inInterface')
3838
->build(),

src/Rules/Properties/PropertyInClassRule.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -109,15 +109,15 @@ public function processNode(Node $node, Scope $scope): array
109109
}
110110

111111
return [
112-
RuleErrorBuilder::message('Property cannot be both final and private.')
112+
RuleErrorBuilder::message('Private property cannot have a final hook.')
113113
->nonIgnorable()
114-
->identifier('property.finalPrivate')
114+
->identifier('property.finalPrivateHook')
115115
->build(),
116116
];
117117
}
118118
}
119119

120-
if ($classReflection->isAbstract() && $node->isAbstract()) {
120+
if ($node->isAbstract()) {
121121
if ($node->isFinal()) {
122122
return [
123123
RuleErrorBuilder::message('Property cannot be both abstract and final.')

tests/PHPStan/Rules/Properties/PropertiesInInterfaceRuleTest.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,19 @@ public function testPhp83AndPropertiesInInterface(): void
2929

3030
$this->analyse([__DIR__ . '/data/properties-in-interface.php'], [
3131
[
32-
'Interfaces cannot include properties.',
32+
'Interfaces can include properties only on PHP 8.4 and later.',
3333
7,
3434
],
3535
[
36-
'Interfaces cannot include properties.',
36+
'Interfaces can include properties only on PHP 8.4 and later.',
3737
9,
3838
],
3939
[
40-
'Interfaces cannot include properties.',
40+
'Interfaces can include properties only on PHP 8.4 and later.',
4141
11,
4242
],
4343
[
44-
'Interfaces cannot include properties.',
44+
'Interfaces can include properties only on PHP 8.4 and later.',
4545
13,
4646
],
4747
]);
@@ -58,11 +58,11 @@ public function testPhp83AndPropertyHooksInInterface(): void
5858

5959
$this->analyse([__DIR__ . '/data/property-hooks-in-interface.php'], [
6060
[
61-
'Interfaces cannot include properties.',
61+
'Interfaces can include properties only on PHP 8.4 and later.',
6262
7,
6363
],
6464
[
65-
'Interfaces cannot include properties.',
65+
'Interfaces can include properties only on PHP 8.4 and later.',
6666
9,
6767
],
6868
]);

tests/PHPStan/Rules/Properties/PropertyInClassRuleTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ public function testPhp84AndPrivateFinalHookedProperties(): void
225225
7,
226226
],
227227
[
228-
'Property cannot be both final and private.',
228+
'Private property cannot have a final hook.',
229229
11,
230230
],
231231
]);

0 commit comments

Comments
 (0)