Hi,

On Thu, Nov 16, 2023 at 8:41 PM Rowan Tommins <rowan.coll...@gmail.com>
wrote:

> Hi all,
>
> I have finally written up an RFC I have been considering for some time:
> Harmonise "untyped" and "typed" properties
>
> RFC URL: https://wiki.php.net/rfc/mixed_vs_untyped_properties
>
>
> Currently, changing a property declaration from "private $foo" to
> "private mixed $foo" changes its behaviour in significant ways, even
> though no actual type checks are added. This RFC seeks to remove those
> differences, by extending the "uninitialized" state currently reserved
> for typed properties to cover all declared properties:
>
> * Properties without an initial value will be "uninitialized", not "null"
> * Calling "unset" on a declared property will make it "uninitialized",
> rather than the current complex behaviour
>
>
> There are a handful of open questions still in the RFC, but I wanted to
> present an initial draft to start the discussion, because the current
> behaviour is quite hard to explain in a short e-mail.
>
> Please let me know your thoughts.
>
>
This sounds like a huge BC break. Probably bigger and a bit harder to fix
than disallowing dynamic props. I have seen is_null and similar checks done
on uninitialized props many times and this will certainly break such cases.
You can say that it just requires adding default null value but that might
not be that simple if you depend on some library or code base is big.

Maybe it would be better to do this as some sort of opt in behaviour using
class attributes which could even disallow untyped props completely as it
would be opt in...

Cheers

Jakub

Reply via email to