Skip to content

Commit 01f9cd9

Browse files
authored
Fix UselessPrivatePropertyNullabilityRule false-positive for promoted properties (#55)
1 parent 3a3f8b1 commit 01f9cd9

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/Rule/UselessPrivatePropertyNullabilityRule.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public function processNode(Node $node, Scope $scope): array
7474
$errors = [];
7575

7676
foreach ($node->getProperties() as $property) {
77-
$shouldBeChecked = $property->isPrivate() || $property->isReadOnly();
77+
$shouldBeChecked = ($property->isPrivate() || $property->isReadOnly()) && !$property->isPromoted();
7878

7979
if (!$shouldBeChecked) {
8080
continue;

tests/Rule/data/UselessPrivatePropertyNullabilityRule/code.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ public function __construct(
2626
int $isPrivate,
2727
int $isPrivateWithConditionalAssignment,
2828
int $isPrivateWithDefaultNull,
29-
int $isPrivateWithDefaultNotNull
29+
int $isPrivateWithDefaultNotNull,
30+
private ?int $isPrivatePromoted
3031
) {
3132
$this->isPublic = $isPublic;
3233
$this->isProtected = $isProtected;

0 commit comments

Comments
 (0)