On 27.05.21 16:43, Rowan Tommins wrote:
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.
How is "uninitialized" magic? It is a state of a class property in PHP
that is currently being exposed via reflection, and I have seen quite a
few places where it occurs - for example with setter injection in
frameworks, as an alternative to setting a property in the constructor.
I also prefer properties with default values or values defined in the
constructor, yet making it easy to check on something that already
exists in the language only seems sensible to me - and I don't see a way
of getting rid of that state anytime soon.
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php