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

From: Date: Sat, 09 Dec 2017 12:46:10 +0000
Subject: Re: instanceof survives non-object variables, but crashes on non-object constants.
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-101279@lists.php.net to get a copy of this message
> > That is fine for code that is broken in the first place. Similarly we added > a warning some years back about array to string conversions. > Code using instanceof on possible non-objects isn't broken. instanceof simply does an implicit is_object() check without needing an extra function call. I know that a change there would break Amp in quite a few places ( https://github.com/amphp/amp/search?utf8=%E2%9C%93&q=instanceof&type=) and I'm very sure that a lot of other applications would break, too. > The impact should be minimal as is, so persevering bc for broken usage is a > poor argument imo > Why is it broken? What's wrong with the implicit is_object() check? 1 instanceof XXX *is clearly broken* on the other hand, which can be statically verified to fail in all cases. Regards, Niklas

« previous php.internals (#101279) next »