Skip to content

Commit 8a1da56

Browse files
committed
Invoke virtual ClassPropertyNode for hooked promoted properties without visibility modifier
1 parent 7e08f0c commit 8a1da56

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

src/Analyser/NodeScopeResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ private function processStmtNode(
645645
$isFromTrait = $stmt->getAttribute('originalTraitMethodName') === '__construct';
646646
if ($isFromTrait || $stmt->name->toLowerString() === '__construct') {
647647
foreach ($stmt->params as $param) {
648-
if ($param->flags === 0) {
648+
if ($param->flags === 0 && $param->hooks === []) {
649649
continue;
650650
}
651651

tests/PHPStan/Rules/Properties/PropertyInClassRuleTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ public function testPhp84AndHookedPropertiesWithoutBodiesInClass(): void
5050
'Non-abstract properties cannot include hooks without bodies.',
5151
9,
5252
],
53+
[
54+
'Non-abstract properties cannot include hooks without bodies.',
55+
15,
56+
],
5357
]);
5458
}
5559

tests/PHPStan/Rules/Properties/data/hooked-properties-without-bodies-in-class.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,13 @@ class AbstractPerson
88

99
public string $lastName { get; set; }
1010
}
11+
12+
class PromotedHookedPropertyWithoutVisibility
13+
{
14+
15+
public function __construct(mixed $test { get; })
16+
{
17+
18+
}
19+
20+
}

0 commit comments

Comments
 (0)