Property hooks is the first PHP feature where static analysis is a must. It's so easy to shoot yourself in the foot.

Here's a property with a set hook that does not actually assign value to the property which is suspicious.

PHPStan will report it as an error:

@OndrejMirtes Nice!

Just make sure it isn't overly aggressive. Writing to another property from the set hook is totally reasonable. Having one virtual and one non-virtual hook, though, I agree I can't see as anything but an error.

@Crell Do you think I should report “this non-virtual property is never read in the get hook”? It’d be a bit more work.

The foundation for the set hook check was mostly there, thanks to (your favourite) uninitialized properties checks 😊

@OndrejMirtes I think that makes sense. A property you can write to with a hook but it's never read seems pointless.
@Crell Alright, was easier than I thought after all:

@OndrejMirtes Nice!

Cc @ilutov in case he has thoughts on this thread.