Hey!

First of all: the idea is very good.
Criticism: Again, that's a new Syntax "feature";

May we deploy this into next releases of PHP?

Thanks!
--
(c) Kenan Sulayman
Freelance Designer and Programmer

Life's Live Poetry


2009/1/21 David Grudl <da...@grudl.com>

> Especially in namespaced code it should be very useful  to have "something"
> returning fully qualified name as string. It can be operator, but I think
> introducing new keyword is bad way, or it can be realized using well known
> magic constant in new context:
>
> Example:
>
> function factory($class)
> {
>   return new $class;
> }
>
> $obj = factory('MyClass'); // returns object MyClass
> $obj = factory(MyClass::__CLASS__); // returns again object MyClass, code
> is little bit more selfexplaining
>
>
> But big advantages are in namespaced code (especially when you refactor a
> code):
>
> namespace Foo;
> use Other\Bar;
>
> $obj = factory('MyClass'); // ERROR - returns object \MyClass, must be
> refactored to:
> $obj = factory(__NAMESPACE__ . '\\MyClass');  // very very ugly! :-(
> $obj = factory('Other\Bar');  // use statement must be duplicated here :-(
>
> // with magic contant:
> $obj = factory(MyClass::__CLASS__);  // returns object Foo\MyClass, very
> understandable :-)
> $obj = factory(Bar::__CLASS__);  // returns object  Other\Bar, as use
> statement declares :-)
>
> David Grudl
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Reply via email to