Re: OBJECT_OPERATOR vs. DOUBLE_COLON
| From: | Andrea Faulds | Date: | Wed, 05 Jul 2017 23:12:40 +0000 |
| Subject: | Re: OBJECT_OPERATOR vs. DOUBLE_COLON | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-99779@lists.php.net to get a copy of this message | ||
Hi Sebastian,
Sebastian Bergmann wrote:
Is it intentional that the DOUBLE_COLON operator can be used on a variable that contains a reference to an object?I assume so. It wouldn't be the only place that accepts either a class name or an object of that class.
I think that using :: on a variable that contains an object should not "fall back" to a static access on the object's class. Instead the runtime should error out. What do you think?I would oppose this; I think it would make PHP less consistent, and as Rowan noted, it's useful for accessing constants of the appropriate class associated to an object. Thanks! -- Andrea Faulds https://ajf.me/