On 16 July 2018 at 16:42, Marco Pivetta <[email protected]> wrote:
> There are naturally 3 states in the engine:
>
> 1 - value set
> 2 - value not set (default `null`)
> 3 - undefined/uninitialised
>
> These have been around since 5.0 AFAIK.
>
"Undefined" and "uninitialised" are not the same state:
class A {
public $alpha = 42;
public $beta;
// no such property as $charlie;
public SomeClass $delta;
}
$a = new A;
$a->alpha; // value set
$a->beta; // value not set (default null)
$a->charlie; // undefined, but still accessible, with implicit value null
$a->delta; // uninitialised; all attempts to access will throw an error
The behaviour of $a->charlie is consistent with other undefined variables
(e.g. a local variable can be read before it is written to). I can't think
of anything in the language which behaves the same way as $a->delta.
Regards,
--
Rowan Collins
[IMSoP]