On regular PHP 7, the array weirdness (Dmitry's last example) doesn't even
produce a warning:

class Shit {
    public $yo = false;
}

$shit = new Shit();

$shit->yo[] = "what"; // quitly turns $yo into an array!

echo gettype($shit->yo); // array

That's pretty messed-up right there. At least in the object cases there's
an E_WARNING "Creating default object from empty value" - with the array
case, nothing, it just converts your boolean into an array. Yiiiiikes.


On Tue, Jan 17, 2017 at 11:03 AM, Dmitry Stogov <dmi...@zend.com> wrote:

> Hi Bob,
>
>
> I've found a number of problems:
>
>
> $ sapi/cli/php -r 'class Foo {public bool $b = false;} $x = new Foo;
> $x->b->ops += 5; echo gettype($x->b),"\n";'
>
> object
>
> $  sapi/cli/php -r 'class Foo {public bool $b = false;} $x = new Foo;
> $x->b->ops++; echo gettype($x->b),"\n";'
> object
>
> $  sapi/cli/php -r 'class Foo {public bool $b = false;} $x = new Foo;
> $x->b->ops = 5; echo gettype($x->b),"\n";'
> object
>
> $  sapi/cli/php -r 'class Foo {public bool $b = false;} $x = new Foo;
> $x->b[] = 5; echo gettype($x->b),"\n";'
> array
>
> Thanks. Dmitry.
>
>

Reply via email to