Re: [RFC][Discussion] Harmonise "untyped" and "typed" properties

From: Date: Fri, 17 Nov 2023 13:30:42 +0000
Subject: Re: [RFC][Discussion] Harmonise "untyped" and "typed" properties
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-121705@lists.php.net to get a copy of this message
> Le 17 nov. 2023 à 11:47, Rowan Tommins <rowan.collins@gmail.com> a écrit : > > On 16 November 2023 21:38:48 GMT, Jakub Zelenka <bukka@php.net> wrote: >> This sounds like a huge BC break. Probably bigger and a bit harder to fix >> than disallowing dynamic props. > > More common, maybe; but trivial to fix: add "=null" at the end of all untyped > property declarations that don't already have an initializer. It would be trivial to automate > with something like Rector. > The fix is trivial, but the number of files to be touched is huge. > >> Maybe it would be better to do this as some sort of opt in behaviour > > We already have the opt-in behaviour: add "mixed" to a property declaration, and it > no longer gets initialized to null. [...] > Yes, except that an untyped (respectively mixed) property cannot be redeclared as mixed (resp. untyped) in a subclass. A small step in the right direction is to allow that. —Claude

« previous php.internals (#121705) next »