Re: Allow arbitrary expressions when using instanceof operator

From: Date: Thu, 06 Nov 2014 09:01:52 +0000
Subject: Re: Allow arbitrary expressions when using instanceof operator
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-78799@lists.php.net to get a copy of this message
Hi! > What I want to implement is the ability to allow arbitrary expressions on > the second operand, so instead of having to write something like this: I'm afraid there's a problem with this. Arbitrary expressions include constants, right? So what this means: var_dump($foo instanceof Bar); is it checking $foo for being instance of class Bar (that's what is happening now) or is it taking the value of the constant Bar (whatever it is) - since constant is an expression - and using it as a class name and then checking if $foo is an instance of that class? You could of course require the expression to always be enclosed in (), but that produces weird syntax where some forms of instanceof work without () and some only with (). Given that you can easily assign your value to a variable, is it worth it? Also, you can always use is_a($foo, $bar->getClassName()). -- Stanislav Malyshev, Software Architect SugarCRM: http://www.sugarcrm.com/

« previous php.internals (#78799) next »