Re: instanceof survives non-object variables, but crasheson non-object constants.
| From: | Christoph M. Becker | Date: | Sun, 10 Dec 2017 12:44:34 +0000 |
| Subject: | Re: instanceof survives non-object variables, but crasheson non-object constants. | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-101290@lists.php.net to get a copy of this message | ||
On 10.12.2017 at 12:05, Niklas Keller wrote:
>> This. There's nothing undefinable about "1 instanceof \stdClass", the
>> clear and obvious answer is: "No, it's not an instance of \stdClass,
>> it's an integer." The runtime result of false makes sense, the
>> compile time error doesn't. Let's relax the compile time error (fold
>> it into a const false if you truly must) and call it done. There's no
>> need to be hostile to users just because the code *seems* silly.
>
> This code doesn't just *seem* silly. For everything but testing whether it
> works it is totally useless.
>
> But we might turn the fatal error into a warning like we do it for "use" in
> the global namespace: https://3v4l.org/ph7KW
I fail to see why
1 instanceof \stdClass
should be handled differently than
1 === (new stdClass)
for instance.
--
Christoph M. Becker