-
Notifications
You must be signed in to change notification settings - Fork 19
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
When I want to use the property hook (only get) on a public readonly property the rule says that the property is not marked as readonly, which is not possible in the interface.
In my opinion, the attached example should be fine.
https://phpstan.org/r/01ab1923-5648-46da-803d-e024aeb82ddf
I have a commit ready to fix it, but I can't push it.
if ($this->phpVersion->supportsPropertyHooks()) {
foreach ($node->getHooks() as $hook) {
if ($hook->name->toString() === 'set') {
$error = RuleErrorBuilder::message("Public property `{$node->getName()}` cannot have a setter hook, because is mark as readonly.")
->identifier('shipmonk.publicPropertyNotReadonly')
->build();
return [$error];
}
}
if ($classReflection->isInterface()) {
return [];
}
}
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working