Bug #80598 [Opn->Nab]: Instanceof does not evaluate expressions in second operand

From: Date: Wed, 06 Jan 2021 13:05:03 +0000
Subject: Bug #80598 [Opn->Nab]: Instanceof does not evaluate expressions in second operand
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-231396@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=80598&edit=1 ID: 80598 Updated by: cmb@php.net Reported by: hello at rapliandras dot hu Summary: Instanceof does not evaluate expressions in second operand -Status: Open +Status: Not a bug Type: Bug Package: Compile Failure Operating System: Ubuntu 20 PHP Version: 7.4.13 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: The right hand side of instanceof expects a class or interface name or an object, but not a string. You cannot store a class or interface name or an object in a class constant, so your code makes no sense. [1] <https://www.php.net/manual/en/language.operators.type.php> Previous Comments: ------------------------------------------------------------------------ [2021-01-06 12:45:23] hello at rapliandras dot hu Description: ------------ Trying the following expression: $entity instanceof (static::BASE_CLASS) I get PHP Parse error: syntax error, unexpected '(' Test script: --------------- $entity instanceof (static::BASE_CLASS) Expected result: ---------------- Even if this is on purpose, or documented, it's not the expected, intuitive behavior. instanceof operator should have no problems with evaluating the right operand Actual result: -------------- PHP Parse error: syntax error, unexpected '(' ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=80598&edit=1

« previous php.bugs (#231396) next »