Allow arbitrary expressions when using instanceof operator
| From: | Daniel Ribeiro | Date: | Thu, 06 Nov 2014 07:41:02 +0000 |
| Subject: | Allow arbitrary expressions when using instanceof operator | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-78787@lists.php.net to get a copy of this message | ||
Good morning, internals!
I would like to present to you an idea that I have for a syntax improvement
for PHP.
The basic idea is to allow arbitrary expressions when using the instanceof
operator. Currently, the second operand can only be a constant reference or
a string:
$foo instanceof stdClass;
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:
$className = 'stdClass';
$foo instanceof $className;
We could write something like this:
$foo instanceof ($bar->getClassName());
I've been working with Nikita Nefedov on this improvement, and we managed
to reach a very simple way to implement it, and it looks pretty good so far.
Currently, I don't have a VCS account, and eventually I want to open a
formal RFC for this, but I first wanted to discuss this with you guys to
see the impressions on it and suggestions as well.
Regarding BC breaks, there would be none from what I can see so far -
hopefully someone more experienced will be able to point my any.
So, what do you think?
Cheers!
Daniel Ribeiro
http://danielribeiro.org