Skip to content

Commit 1cc5347

Browse files
committed
Do not check abstract properties as uninitialized
1 parent f436584 commit 1cc5347

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

src/Node/ClassPropertiesNode.php

+3
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ public function getUninitializedProperties(
118118
if ($property->isStatic()) {
119119
continue;
120120
}
121+
if ($property->isAbstract()) {
122+
continue;
123+
}
121124
if ($property->getNativeType() === null) {
122125
continue;
123126
}

tests/PHPStan/Rules/Properties/UninitializedPropertyRuleTest.php

+10
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use PHPStan\Rules\Rule;
88
use PHPStan\Testing\RuleTestCase;
99
use function strpos;
10+
use const PHP_VERSION_ID;
1011

1112
/**
1213
* @extends RuleTestCase<UninitializedPropertyRule>
@@ -216,4 +217,13 @@ public function testRedeclareReadonlyProperties(): void
216217
]);
217218
}
218219

220+
public function testBug12336(): void
221+
{
222+
if (PHP_VERSION_ID < 80400) {
223+
$this->markTestSkipped('Test requires PHP 8.4.');
224+
}
225+
226+
$this->analyse([__DIR__ . '/data/bug-12336.php'], []);
227+
}
228+
219229
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php // lint >= 8.4
2+
3+
namespace Bug12336;
4+
5+
abstract class ListItem {
6+
abstract public int $item { get; }
7+
}

0 commit comments

Comments
 (0)