I think the syntax is wired.
Instead of classname::class I would prefer something like class(classname).


I am not a big fan of the syntax class(ShortClass\Name) as to me it looks like a function call.

Personally, I like drawing parallels from the same languages that I think helped shaped PHP's object-model. In this case, the Java has a similar enough feature where Type.class returns a class object (in our case we just need to return a string of the FQ class name).

Your suggestion is similar to that of, I think, C# where typeof(SomeClassName) would return a reflection-like/type object where you could get the FullName():

http://msdn.microsoft.com/en-us/library/58918ffs%28v=vs.71%29.aspx

I could go either way, at this point (after the April discussion on the matter), I had not really given much thought to class() lang. construct.

Personally, ::class feels a bit better to me in that the context feels more "compile-time", like __CLASS__, and the NS resolutions, than does class() that you suggest.

From a wider perspective, I've seen these variations in the wild:

class Foo {
  const CLASSNAME = __CLASS__;
  // or
  const _class = __CLASS__;
}

Which allows for the usage:

  Foo::CLASSNAME;

for example.

FWIW, both reusing the class() keyword making it BC, which is something I like.

-ralph



--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to