Skip to content

Commit 98d9f06

Browse files
phpstan-botclaude
authored andcommitted
Move readonly checks into hasRestrictedWriteAccess method
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 2da3c78 commit 98d9f06

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Rules/Generics/PropertyVarianceRule.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function processNode(Node $node, Scope $scope): array
4545
return [];
4646
}
4747

48-
$variance = $node->isReadOnly() || $node->isReadOnlyByPhpDoc() || $this->hasRestrictedWriteAccess($node)
48+
$variance = $this->hasRestrictedWriteAccess($node)
4949
? TemplateTypeVariance::createCovariant()
5050
: TemplateTypeVariance::createInvariant();
5151

@@ -58,6 +58,10 @@ public function processNode(Node $node, Scope $scope): array
5858

5959
private function hasRestrictedWriteAccess(ClassPropertyNode $node): bool
6060
{
61+
if ($node->isReadOnly() || $node->isReadOnlyByPhpDoc()) {
62+
return true;
63+
}
64+
6165
if ($node->isPrivateSet()) {
6266
return true;
6367
}

0 commit comments

Comments
 (0)