Skip to content

Commit b4f1197

Browse files
committed
simplify
1 parent b7e6d0f commit b4f1197

File tree

3 files changed

+11
-12
lines changed

3 files changed

+11
-12
lines changed

src/Php/PhpVersion.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ public function supportsPropertyHooks(): bool
357357
return $this->versionId >= 80400;
358358
}
359359

360-
public function supportsNonPrivateFinalProperties(): bool
360+
public function supportsFinalProperties(): bool
361361
{
362362
return $this->versionId >= 80400;
363363
}

src/Rules/Properties/PropertyInClassRule.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,10 @@ public function processNode(Node $node, Scope $scope): array
8383

8484
if (
8585
$node->isFinal()
86-
&& !$node->hasHooks()
87-
&& (!$this->phpVersion->supportsNonPrivateFinalProperties() || $node->isPrivate())
86+
&& !$this->phpVersion->supportsFinalProperties()
8887
) {
8988
return [
90-
RuleErrorBuilder::message('Properties cannot be final.')
89+
RuleErrorBuilder::message('Property cannot be final.')
9190
->nonIgnorable()
9291
->identifier('property.final')
9392
->build(),
@@ -97,7 +96,7 @@ public function processNode(Node $node, Scope $scope): array
9796
if ($node->isPrivate()) {
9897
if ($node->isFinal()) {
9998
return [
100-
RuleErrorBuilder::message('Properties cannot be both final and private.')
99+
RuleErrorBuilder::message('Property cannot be both final and private.')
101100
->nonIgnorable()
102101
->identifier('property.finalPrivate')
103102
->build(),
@@ -110,7 +109,7 @@ public function processNode(Node $node, Scope $scope): array
110109
}
111110

112111
return [
113-
RuleErrorBuilder::message('Properties cannot be both final and private.')
112+
RuleErrorBuilder::message('Property cannot be both final and private.')
114113
->nonIgnorable()
115114
->identifier('property.finalPrivate')
116115
->build(),

tests/PHPStan/Rules/Properties/PropertyInClassRuleTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -221,11 +221,11 @@ public function testPhp84AndPrivateFinalHookedProperties(): void
221221

222222
$this->analyse([__DIR__ . '/data/private-final-property-hooks.php'], [
223223
[
224-
'Properties cannot be both final and private.',
224+
'Property cannot be both final and private.',
225225
7,
226226
],
227227
[
228-
'Properties cannot be both final and private.',
228+
'Property cannot be both final and private.',
229229
11,
230230
],
231231
]);
@@ -239,7 +239,7 @@ public function testPhp84FinalProperties(): void
239239

240240
$this->analyse([__DIR__ . '/data/final-properties.php'], [
241241
[
242-
'Properties cannot be final.',
242+
'Property cannot be both final and private.',
243243
7,
244244
],
245245
]);
@@ -252,15 +252,15 @@ public function testBeforePhp84FinalProperties(): void
252252

253253
$this->analyse([__DIR__ . '/data/final-properties.php'], [
254254
[
255-
'Properties cannot be final.',
255+
'Property cannot be final.',
256256
7,
257257
],
258258
[
259-
'Properties cannot be final.',
259+
'Property cannot be final.',
260260
8,
261261
],
262262
[
263-
'Properties cannot be final.',
263+
'Property cannot be final.',
264264
9,
265265
],
266266
]);

0 commit comments

Comments
 (0)