Re: New Feature: Fully qualified class name resolution as scalar with class keyword
| From: | Nikita Popov | Date: | Tue, 17 Apr 2012 19:41:01 +0000 |
| Subject: | Re: New Feature: Fully qualified class name resolution as scalar with class keyword | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-60104@lists.php.net to get a copy of this message | ||
On Tue, Apr 17, 2012 at 9:36 PM, Galen Wright-Watson <ww.galen@gmail.com> wrote:
>Would it be easy to have a patch that simply allows use of the class name,
> or is the "::class" suffix necessary to resolve some ambiguity? Example
> usage:
>
> $mock = $this->getMock(A\Namespaced\**ClassName);
> # or
> use A\Namespaced\ClassName;
> $mock = $this->getMock(ClassName);
>
> Would changing the definition for class_name_scalar be sufficient?
>
> class_name_scalar:
> class_name { zend_resolve_class_name(&$1, ZEND_FETCH_CLASS_GLOBAL,
> 1 TSRMLS_CC); $$ = $1; }
> ;
>
> To my eye, this is the least surprising syntax.
In your above example ClassName could just as well be a constant :)
Nikita