On Wed, Aug 15, 2012 at 2:09 PM, Paul Dragoonis <dragoo...@gmail.com> wrote:
> Comments inline. > > On Wed, Aug 15, 2012 at 11:59 AM, Giedrius Dubinskas > <d.giedr...@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() > > Then you're confusing the reader, they think you're calling a > function, but you're actually calling a class method. Confusion++ > > > fooBar(); // would call Some\Foo::bar() > > What if a function called staticMethod() already exists, there'd be a > bunch of confusion on referring to the right one. > > > > > 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". > > When you find a function call, you'd have to scroll up to the top of > the page to see if it's actually a method alias. In this case being > explicit is a good thing, no scrolling, no confusion. > > > > > Aliasing class constants like that would also be very nice. > > > > What does everyone think? > > Would it be possible in PHP? > > > > -- > > Giedrius Dubinskas > > Not that I don't welcome your suggestions, I encourage them, but for > this paritcular one I vote -1 on it. > > Thanks. > > > > > -- > > PHP Internals - PHP Runtime Development Mailing List > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > Hi, To be honest, I'm not a fan of aliasing - and Paul supplied some of the reasons that stands for me. When one see an class / function declaration - I think that it'll make confuse if he/she'll have to look if this is an alias or not. Besides of that, there's still the issue of "overriding existing functions" rules which can confuse the user. Put that aside, if you can bring some example of good practice it'll be great :) Regards, Yahav.