Re: Consensus Gathering: is_initialized
| From: | David Gebler | Date: | Wed, 26 May 2021 21:27:45 +0000 |
| Subject: | Re: Consensus Gathering: is_initialized | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-114626@lists.php.net to get a copy of this message | ||
On Wed, May 26, 2021 at 11:14 AM Joe Watkins <krakjoe@php.net> wrote:
> Hi internals,
>
> In response to: https://bugs.php.net/bug.php?id=78480
>
> I implemented: https://github.com/php/php-src/pull/7029
>
> Not absolutely convinced that it's a good idea, I asked Nikita to review,
> and he's unconvinced also and suggested a discussion should be started.
>
>
I would just like to second (or third, or fourth) the notion that the very
possibility of accessing uninitialized state is a bug in the user's code,
not a problem for which the language should provide a workaround. If a
property is required (i.e. not nullable) it should absolutely and always be
initialized in the constructor.
I do appreciate PHP being how it is, there might be "valid" use cases for
is_initialized() but I also think it will encourage bad practice.
Regards
Dave