Re: Consensus Gathering: is_initialized

From: Date: Thu, 27 May 2021 14:43:45 +0000
Subject: Re: Consensus Gathering: is_initialized
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-114643@lists.php.net to get a copy of this message
On 27/05/2021 14:55, Andreas Leathley wrote:
When using isset on a non-nullable property a static analyzer would rightfully complain that the property is not nullable
Precisely, so don't mark a property as non-nullable and then leave it unset.
isset in this case is abused to check for uninitialized, hiding the actual intent
On the contrary, the uninitialized state is what is being abused. If you want to make the intent clear, use a clear flag of "needs lazy-loading", or whatever you're actually using this magic "not null but not really anything else either" state for. Regards, -- Rowan Tommins [IMSoP]

« previous php.internals (#114643) next »