Skip to content

Commit

Permalink
Do not check abstract properties as uninitialized
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Jan 24, 2025
1 parent f436584 commit 1cc5347
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Node/ClassPropertiesNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ public function getUninitializedProperties(
if ($property->isStatic()) {
continue;
}
if ($property->isAbstract()) {
continue;
}
if ($property->getNativeType() === null) {
continue;
}
Expand Down
10 changes: 10 additions & 0 deletions tests/PHPStan/Rules/Properties/UninitializedPropertyRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use PHPStan\Rules\Rule;
use PHPStan\Testing\RuleTestCase;
use function strpos;
use const PHP_VERSION_ID;

/**
* @extends RuleTestCase<UninitializedPropertyRule>
Expand Down Expand Up @@ -216,4 +217,13 @@ public function testRedeclareReadonlyProperties(): void
]);
}

public function testBug12336(): void
{
if (PHP_VERSION_ID < 80400) {
$this->markTestSkipped('Test requires PHP 8.4.');
}

$this->analyse([__DIR__ . '/data/bug-12336.php'], []);
}

}
7 changes: 7 additions & 0 deletions tests/PHPStan/Rules/Properties/data/bug-12336.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php // lint >= 8.4

namespace Bug12336;

abstract class ListItem {
abstract public int $item { get; }
}

0 comments on commit 1cc5347

Please sign in to comment.