On 8-4-2024 23:39, Ilija Tovilo wrote:
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
Ilija,
Heads-up: I'm still writing up an opinion and intend to send it to the
list before end of day (CET). I know I'm late to the party, but I've
been having trouble finding the words to express myself properly
regarding this RFC (and have been struggling to find the right words for
months).
Smile,
Juliette