Skip to content

Commit

Permalink
GetNonVirtualPropertyHookReadRule - do not report if get hook is not …
Browse files Browse the repository at this point in the history
…present at all
  • Loading branch information
ondrejmirtes committed Jan 2, 2025
1 parent a742e51 commit b614f70
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/Rules/Properties/GetNonVirtualPropertyHookReadRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,17 @@ public function processNode(Node $node, Scope $scope): array

$errors = [];
foreach ($node->getProperties() as $propertyNode) {
if (!$propertyNode->hasHooks()) {
$hasGetHook = false;
foreach ($propertyNode->getHooks() as $hook) {
if ($hook->name->toLowerString() !== 'get') {
continue;
}

$hasGetHook = true;
break;
}

if (!$hasGetHook) {
continue;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,12 @@ class Foo
}

}

class GetHookIsNotPresentAtAll
{
public int $i {
set {
$this->i = $value + 10;
}
}
}

0 comments on commit b614f70

Please sign in to comment.