Skip to content

Commit 0d3edef

Browse files
committed
Cosmetics according to my taste
1 parent 07c90ab commit 0d3edef

File tree

4 files changed

+44
-44
lines changed

4 files changed

+44
-44
lines changed

src/Rules/Properties/PropertiesInInterfaceRule.php

Lines changed: 4 additions & 4 deletions
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 may not include properties.')
35+
RuleErrorBuilder::message('Interfaces cannot include properties.')
3636
->nonIgnorable()
3737
->identifier('property.inInterface')
3838
->build(),
@@ -41,7 +41,7 @@ public function processNode(Node $node, Scope $scope): array
4141

4242
if (!$node->hasHooks()) {
4343
return [
44-
RuleErrorBuilder::message('Interfaces may only include hooked properties.')
44+
RuleErrorBuilder::message('Interfaces can only include hooked properties.')
4545
->nonIgnorable()
4646
->identifier('property.nonHookedInInterface')
4747
->build(),
@@ -50,7 +50,7 @@ public function processNode(Node $node, Scope $scope): array
5050

5151
if (!$node->isPublic()) {
5252
return [
53-
RuleErrorBuilder::message('Interfaces may not include non-public properties.')
53+
RuleErrorBuilder::message('Interfaces cannot include non-public properties.')
5454
->nonIgnorable()
5555
->identifier('property.nonPublicInInterface')
5656
->build(),
@@ -59,7 +59,7 @@ public function processNode(Node $node, Scope $scope): array
5959

6060
if ($this->hasAnyHookBody($node)) {
6161
return [
62-
RuleErrorBuilder::message('Interfaces may not include property hooks with bodies.')
62+
RuleErrorBuilder::message('Interfaces cannot include property hooks with bodies.')
6363
->nonIgnorable()
6464
->identifier('property.hookBodyInInterface')
6565
->build(),

src/Rules/Properties/PropertyInClassRule.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -32,26 +32,26 @@ public function processNode(Node $node, Scope $scope): array
3232
return [];
3333
}
3434

35-
if (!$this->phpVersion->supportsPropertyHooks() && $node->hasHooks()) {
36-
return [
37-
RuleErrorBuilder::message('Property hooks in classes are supported only on PHP 8.4 and later.')
38-
->nonIgnorable()
39-
->identifier('property.unsupportedHooksInClass')
40-
->build(),
41-
];
42-
}
43-
4435
if (!$this->phpVersion->supportsPropertyHooks()) {
36+
if ($node->hasHooks()) {
37+
return [
38+
RuleErrorBuilder::message('Property hooks are supported only on PHP 8.4 and later.')
39+
->nonIgnorable()
40+
->identifier('property.hooksNotSupported')
41+
->build(),
42+
];
43+
}
44+
4545
return [];
4646
}
4747

4848
if ($classReflection->isAbstract()) {
4949
if ($node->isAbstract()) {
5050
if (!$node->hasHooks()) {
5151
return [
52-
RuleErrorBuilder::message('Only hooked properties may be declared abstract.')
52+
RuleErrorBuilder::message('Only hooked properties can be declared abstract.')
5353
->nonIgnorable()
54-
->identifier('property.nonHookedAbstractInClass')
54+
->identifier('property.abstractNonHooked')
5555
->build(),
5656
];
5757
}
@@ -60,7 +60,7 @@ public function processNode(Node $node, Scope $scope): array
6060
return [
6161
RuleErrorBuilder::message('Abstract properties must specify at least one abstract hook.')
6262
->nonIgnorable()
63-
->identifier('property.hookedAbstractWithBodies')
63+
->identifier('property.abstractWithoutAbstractHook')
6464
->build(),
6565
];
6666
}
@@ -69,9 +69,9 @@ public function processNode(Node $node, Scope $scope): array
6969
if (!$node->isAbstract()) {
7070
if ($node->hasHooks()) {
7171
return [
72-
RuleErrorBuilder::message('Abstract classes may not include non-abstract hooked properties without bodies.')
72+
RuleErrorBuilder::message('Abstract classes cannot include non-abstract hooked properties without bodies.')
7373
->nonIgnorable()
74-
->identifier('property.nonAbstractHookedWithoutBodyInAbstractClass')
74+
->identifier('property.nonAbstractWithAbstractHook')
7575
->build(),
7676
];
7777
}
@@ -83,18 +83,18 @@ public function processNode(Node $node, Scope $scope): array
8383
if ($node->hasHooks()) {
8484
if ($node->isAbstract()) {
8585
return [
86-
RuleErrorBuilder::message('Classes may not include abstract hooked properties.')
86+
RuleErrorBuilder::message('Non-abstract classes cannot include abstract properties.')
8787
->nonIgnorable()
88-
->identifier('property.abstractHookedInClass')
88+
->identifier('property.abstract')
8989
->build(),
9090
];
9191
}
9292

9393
if (!$this->doAllHooksHaveBody($node)) {
9494
return [
95-
RuleErrorBuilder::message('Non-abstract classes may not include hooked properties without bodies.')
95+
RuleErrorBuilder::message('Non-abstract properties cannot include hooks without bodies.')
9696
->nonIgnorable()
97-
->identifier('property.hookedWithoutBodyInClass')
97+
->identifier('property.hookWithoutBody')
9898
->build(),
9999
];
100100
}

tests/PHPStan/Rules/Properties/PropertiesInInterfaceRuleTest.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ public function testPhp83AndPropertiesInInterface(): void
2929

3030
$this->analyse([__DIR__ . '/data/properties-in-interface.php'], [
3131
[
32-
'Interfaces may not include properties.',
32+
'Interfaces cannot include properties.',
3333
7,
3434
],
3535
[
36-
'Interfaces may not include properties.',
36+
'Interfaces cannot include properties.',
3737
9,
3838
],
3939
[
40-
'Interfaces may not include properties.',
40+
'Interfaces cannot include properties.',
4141
11,
4242
],
4343
]);
@@ -54,11 +54,11 @@ public function testPhp83AndPropertyHooksInInterface(): void
5454

5555
$this->analyse([__DIR__ . '/data/property-hooks-in-interface.php'], [
5656
[
57-
'Interfaces may not include properties.',
57+
'Interfaces cannot include properties.',
5858
7,
5959
],
6060
[
61-
'Interfaces may not include properties.',
61+
'Interfaces cannot include properties.',
6262
9,
6363
],
6464
]);
@@ -72,11 +72,11 @@ public function testPhp84AndPropertiesInInterface(): void
7272

7373
$this->analyse([__DIR__ . '/data/properties-in-interface.php'], [
7474
[
75-
'Interfaces may only include hooked properties.',
75+
'Interfaces can only include hooked properties.',
7676
9,
7777
],
7878
[
79-
'Interfaces may only include hooked properties.',
79+
'Interfaces can only include hooked properties.',
8080
11,
8181
],
8282
]);
@@ -90,11 +90,11 @@ public function testPhp84AndNonPublicPropertyHooksInInterface(): void
9090

9191
$this->analyse([__DIR__ . '/data/property-hooks-visibility-in-interface.php'], [
9292
[
93-
'Interfaces may not include non-public properties.',
93+
'Interfaces cannot include non-public properties.',
9494
7,
9595
],
9696
[
97-
'Interfaces may not include non-public properties.',
97+
'Interfaces cannot include non-public properties.',
9898
9,
9999
],
100100
]);
@@ -108,11 +108,11 @@ public function testPhp84AndPropertyHooksWithBodiesInInterface(): void
108108

109109
$this->analyse([__DIR__ . '/data/property-hooks-bodies-in-interface.php'], [
110110
[
111-
'Interfaces may not include property hooks with bodies.',
111+
'Interfaces cannot include property hooks with bodies.',
112112
7,
113113
],
114114
[
115-
'Interfaces may not include property hooks with bodies.',
115+
'Interfaces cannot include property hooks with bodies.',
116116
13,
117117
],
118118
]);

tests/PHPStan/Rules/Properties/PropertyInClassRuleTest.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function testPhpLessThan84AndHookedPropertiesInClass(): void
2929

3030
$this->analyse([__DIR__ . '/data/hooked-properties-in-class.php'], [
3131
[
32-
'Property hooks in classes are supported only on PHP 8.4 and later.',
32+
'Property hooks are supported only on PHP 8.4 and later.',
3333
7,
3434
],
3535
]);
@@ -43,11 +43,11 @@ public function testPhp84AndHookedPropertiesWithoutBodiesInClass(): void
4343

4444
$this->analyse([__DIR__ . '/data/hooked-properties-without-bodies-in-class.php'], [
4545
[
46-
'Non-abstract classes may not include hooked properties without bodies.',
46+
'Non-abstract properties cannot include hooks without bodies.',
4747
7,
4848
],
4949
[
50-
'Non-abstract classes may not include hooked properties without bodies.',
50+
'Non-abstract properties cannot include hooks without bodies.',
5151
9,
5252
],
5353
]);
@@ -61,11 +61,11 @@ public function testPhp84AndNonAbstractHookedPropertiesInClass(): void
6161

6262
$this->analyse([__DIR__ . '/data/non-abstract-hooked-properties-in-class.php'], [
6363
[
64-
'Non-abstract classes may not include hooked properties without bodies.',
64+
'Non-abstract properties cannot include hooks without bodies.',
6565
7,
6666
],
6767
[
68-
'Non-abstract classes may not include hooked properties without bodies.',
68+
'Non-abstract properties cannot include hooks without bodies.',
6969
9,
7070
],
7171
]);
@@ -79,11 +79,11 @@ public function testPhp84AndAbstractHookedPropertiesInClass(): void
7979

8080
$this->analyse([__DIR__ . '/data/abstract-hooked-properties-in-class.php'], [
8181
[
82-
'Classes may not include abstract hooked properties.',
82+
'Non-abstract classes cannot include abstract properties.',
8383
7,
8484
],
8585
[
86-
'Classes may not include abstract hooked properties.',
86+
'Non-abstract classes cannot include abstract properties.',
8787
9,
8888
],
8989
]);
@@ -97,11 +97,11 @@ public function testPhp84AndNonAbstractHookedPropertiesInAbstractClass(): void
9797

9898
$this->analyse([__DIR__ . '/data/non-abstract-hooked-properties-in-abstract-class.php'], [
9999
[
100-
'Abstract classes may not include non-abstract hooked properties without bodies.',
100+
'Abstract classes cannot include non-abstract hooked properties without bodies.',
101101
7,
102102
],
103103
[
104-
'Abstract classes may not include non-abstract hooked properties without bodies.',
104+
'Abstract classes cannot include non-abstract hooked properties without bodies.',
105105
9,
106106
],
107107
]);
@@ -115,11 +115,11 @@ public function testPhp84AndAbstractNonHookedPropertiesInAbstractClass(): void
115115

116116
$this->analyse([__DIR__ . '/data/abstract-non-hooked-properties-in-abstract-class.php'], [
117117
[
118-
'Only hooked properties may be declared abstract.',
118+
'Only hooked properties can be declared abstract.',
119119
7,
120120
],
121121
[
122-
'Only hooked properties may be declared abstract.',
122+
'Only hooked properties can be declared abstract.',
123123
9,
124124
],
125125
]);

0 commit comments

Comments
 (0)