Re: Proposal: use SomeClass::staticMethod

From: Date: Wed, 15 Aug 2012 11:18:54 +0000
Subject: Re: Proposal: use SomeClass::staticMethod
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-62186@lists.php.net to get a copy of this message
On Wed, Aug 15, 2012 at 12:59 PM, Giedrius Dubinskas <d.giedrius@gmail.com> wrote: > Hello Internals! > > I'm just on and off luker here but thought I'll throw in an idea for a > feature I'd love to see in PHP: aliasing static methods. > > Syntax would look something like this: > > use Namespaced\SomeClass::staticMethod; > use Some\Foo::bar as fooBar; > > staticMethod(); // would call Namespaced\SomeClass::staticMethod() > fooBar(); // would call Some\Foo::bar() > > This would make code more readable, by removing the the noise of > repetition of class names. For use cases we can look at Java use cases > for "import static". > > Aliasing class constants like that would also be very nice. > > What does everyone think? I have the suspicion that you are just using static methods as a way to group functions into a "namespace". If that's what you want, then why not just use namespaced functions for that? Should be a lot less confusing and also semantically more correct. Nikita

« previous php.internals (#62186) next »