[php-src] PR #22375: Zend: Make `instanceof object` equivalent to `is_object()`
| From: | dseguy | Date: | Sun, 21 Jun 2026 10:30:27 +0000 |
| Subject: | [php-src] PR #22375: Zend: Make `instanceof object` equivalent to `is_object()` | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-36523@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/22375
Author: dseguy
$x instanceof object was syntactically valid but always returned false because
object is a pseudo-type with no corresponding class entry in the class table. This made
the construct silently unusable.
At compile time, when the right-hand side of instanceof is the literal
object pseudo-type, emit ZEND_TYPE_CHECK with MAY_BE_OBJECT
instead of ZEND_INSTANCEOF. This is the same opcode used by is_object(),
so $x instanceof object now behaves identically to is_object($x).
The fix is entirely at compile time; no VM handler changes are required.