Re: New Feature: Fully qualified class name resolution as scalar with class keyword
| From: | Matthew Weier O'Phinney | Date: | Tue, 17 Apr 2012 15:20:29 +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-60083@lists.php.net to get a copy of this message | ||
On 2012-04-17, Ralph Schindler <ralph@ralphschindler.com> wrote:
> Hi Nikita,
>
> > A quick note on the patch: As the class name is compile-time
> > resolvable it should in my eyes also be available as a
> >
static_scalar, so that it can be used in initialization
> > lists:
> >
> > public function doFoo($withClass = ABC::class) {
> > new $withClass; // or whatever
> > }
> >
> > To be available as both a static_scalar and a general
> > scalar one
> > should put the rule in the common_scalar section.
> >
> > What do you think?
>
> I've added this to the patch and Zend/tests:
>
> *
> ¼
> «�v•Íþj?Œ'7ßhttps://github.com/ralphschindler/php-src/compare/master...feature/class-name-scalar
>
> I've also added an RFC page, any thoughts on improving the RFC?
>
> * https://wiki.php.net/rfc/class_name_scalars
In the examples, you mix case:
Boo::class
Moo::Class
\Moo::CLASS
Make sure you note that this is intentional, and that the keyword is
case insensitive -- i.e., changing the case does not alter the use cases
presented.
Also, I'd note why you're selecting "class" as the keyword (basically,
because it _is_ a keyword, and thus will never conflict with any class
constants or method names).
Otherwise, very straight-forward.
--
Matthew Weier O'Phinney
Project Lead | matthew@zend.com
Zend Framework | http://framework.zend.com/
PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc