[RFC][Vote announcement] Property hooks
| From: | Ilija Tovilo | Date: | Mon, 08 Apr 2024 21:39:34 +0000 |
| Subject: | [RFC][Vote announcement] Property hooks | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-123048@lists.php.net to get a copy of this message | ||
Hi everyone
Heads-up: Larry and I would like to start the vote of the property
hooks RFC tomorrow:
https://wiki.php.net/rfc/property-hooks
We have worked long and hard on this RFC, and hope that we have found
some middle-ground that works for the majority. One last concern we
have not officially clarified on the list:
https://externals.io/message/122445#122667
>> I personally do not feel strongly about whether asymmetric types make it into the initial
>> implementation. Larry does, however, and I think it is not fair to exclude them without providing
>> any concrete reasons not to. [snip]
>
> My concern is more about the external impact of what is effectively a change to the type system
> of the language: [snip] will tools like PhpStan and Psalm require complex changes to analyse code
> using such properties?
In particular, this paragraph is referencing the ability to widen the
accepted $value parameter type of the set hook, described at the
bottom of https://wiki.php.net/rfc/property-hooks#set.
I have talked
to Ondřej Mirtes, the maintainer of PHPStan, and he confirmed that
this should not be complex to implement in PHPStan. In fact, PHPStan
already offers the @property-read and @property-write class
annotations, which can be used to describe "virtual" properties
handled within __get/__set, already providing asymmetric types of
sorts. Hence, this concern should be a non-issue.
Thank you to everybody who has contributed to the discussion!
Ilija