Re: [RFC] Allow ::class on objects
| From: | Mike Schinkel | Date: | Thu, 09 Jan 2020 20:40:50 +0000 |
| Subject: | Re: [RFC] Allow ::class on objects | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-108073@lists.php.net to get a copy of this message | ||
> On Jan 9, 2020, at 3:29 PM, Ralph Schindler <ralph@ralphschindler.com> wrote:How would
> you get the right semantics out of $object::interface, or $object::trait, and/or do you have an
> example of what you're expecting?
Sorry, I was only thinking about using it on Interface and Trait names, not on objects.
I have a lot of code that looks like this:
use Interfaces;
if ( ! implements_interface( $object, Interfaces\MyInterface::class, $trigger_error = true )) {
return;
}
And it feels wrong. I would love to be able to use ::interface, i.e.:
use Interfaces;
if ( implements_interface( $object, Interfaces\MyInterface::interface, $trigger_error = true )) {
return;
}
-Mike