Re: Allow arbitrary expressions when using instanceof operator
| From: | Daniel Ribeiro | Date: | Thu, 06 Nov 2014 09:29:37 +0000 |
| Subject: | Re: Allow arbitrary expressions when using instanceof operator | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-78801@lists.php.net to get a copy of this message | ||
On Thu, Nov 6, 2014 at 1:01 PM, Stas Malyshev <smalyshev@sugarcrm.com>
wrote:
> 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()).
>
This is exactly what I'm doing right now, requiring the expression to
always be enclosed in parenthesis. I think it's way better to be able to do
this instead of creating temporary variables just to assign a class name.
Also, is_a, since it's a function, is significantly slower than instanceof,
which is a construct (but of course you already now that).
Daniel Ribeiro
http://danielribeiro.org