Re: instanceof survives non-object variables, but crashes on non-object constants.

From: Date: Sat, 09 Dec 2017 06:35:30 +0000
Subject: Re: instanceof survives non-object variables, but crashes on non-object constants.
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-101274@lists.php.net to get a copy of this message
Hi We should just add a warning to the first example, it seems like an oversight that it was left silent On 9 Dec 2017 07.29, "Andreas Hennings" <andreas@dqxtech.net> wrote: > The following (https://3v4l.org/A2Tp6) is ok, it simply returns false: > > $x = 1; > $x instanceof \stdClass; > > > The following (https://3v4l.org/IdSBu) gives a fatal error: > > 1 instanceof \stdclass; > > t think this behavior is inconsistent, and we should consider changing it. > > There are two options, but only one is BC. > > - Let 1 instanceof \stdClass return false, instead of crashing. -> seems BC > - Let $x instanceof \stdClass crash, if $x is not an object. -> BC break. > > So it seems the first would the option we should take. > This is also what hhvm does, according to > https://3v4l.org/IdSBu. >

« previous php.internals (#101274) next »