Skip to content

Commit 2d24ffc

Browse files
authored
Fix GetNonVirtualPropertyHookReadRule on abstract property
1 parent 6b0d8c3 commit 2d24ffc

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

Diff for: src/Rules/Properties/GetNonVirtualPropertyHookReadRule.php

+4
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ public function processNode(Node $node, Scope $scope): array
7676
continue;
7777
}
7878

79+
if ($hook->body === null) {
80+
continue;
81+
}
82+
7983
$hasGetHook = true;
8084
break;
8185
}

Diff for: tests/PHPStan/Rules/Properties/GetNonVirtualPropertyHookReadRuleTest.php

+9
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,13 @@ public function testRule(): void
3535
]);
3636
}
3737

38+
public function testAbstractProperty(): void
39+
{
40+
if (PHP_VERSION_ID < 80400) {
41+
$this->markTestSkipped('Test requires PHP 8.4.');
42+
}
43+
44+
$this->analyse([__DIR__ . '/data/get-abstract-property-hook-read.php'], []);
45+
}
46+
3847
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php // lint >= 8.4
2+
3+
namespace GetAbstractPropertyHook;
4+
5+
class NonFinalClass
6+
{
7+
public string $publicProperty;
8+
}
9+
10+
abstract class Foo extends NonFinalClass
11+
{
12+
abstract public string $publicProperty {
13+
get;
14+
}
15+
}

0 commit comments

Comments
 (0)