Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:62187 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 30230 invoked from network); 15 Aug 2012 11:19:29 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Aug 2012 11:19:29 -0000 Authentication-Results: pb1.pair.com smtp.mail=g.b.yahav@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=g.b.yahav@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.220.170 as permitted sender) X-PHP-List-Original-Sender: g.b.yahav@gmail.com X-Host-Fingerprint: 209.85.220.170 mail-vc0-f170.google.com Received: from [209.85.220.170] ([209.85.220.170:48857] helo=mail-vc0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 44/17-30529-0C58B205 for ; Wed, 15 Aug 2012 07:19:29 -0400 Received: by vcbgb30 with SMTP id gb30so1544793vcb.29 for ; Wed, 15 Aug 2012 04:19:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=V5w+nvxILet/n2HIBK5ILYgULIFGXV9bOBQ7bQPz9iQ=; b=qhyZ/kCQozpVQKFZTvyJpp7xvRrMRAKsJujaXYfJQulMAB39RPX7lWydzgho+N4Ar+ usiHuN6QWJCGfLqHmWvhNDoMAS7J7h1AQpHzIOSoAd8r8Zz6mw4jGLSh6hL4oRA9ko0e eKIITVvXKghtRIXidsIO4/hh1AdRUPF2j0r9QEpEMkOFmroZzDIiOpTACvysYpzVyFlT qaEMqIIM8K65o7DxS5tQdMFPtq7lRmDdsREZ8nR4QarNoFtn5NJmCQ7kZHmgW2b5OJaP PwFSOY3qgSTzOcEwvp43t+haxZzYo5FSlSXu+0cv5f+Y5zhChtzlFLh6u0JUDgeU3Hb+ +n/g== Received: by 10.220.221.72 with SMTP id ib8mr12620741vcb.25.1345029565880; Wed, 15 Aug 2012 04:19:25 -0700 (PDT) MIME-Version: 1.0 Received: by 10.52.109.230 with HTTP; Wed, 15 Aug 2012 04:19:05 -0700 (PDT) In-Reply-To: References: Date: Wed, 15 Aug 2012 14:19:05 +0300 Message-ID: To: Paul Dragoonis Cc: Giedrius Dubinskas , internals@lists.php.net Content-Type: multipart/alternative; boundary=14dae9cfc88a7c99b404c74c19d2 Subject: Re: [PHP-DEV] Proposal: use SomeClass::staticMethod From: g.b.yahav@gmail.com (Yahav Gindi Bar) --14dae9cfc88a7c99b404c74c19d2 Content-Type: text/plain; charset=ISO-8859-1 On Wed, Aug 15, 2012 at 2:09 PM, Paul Dragoonis wrote: > Comments inline. > > On Wed, Aug 15, 2012 at 11:59 AM, Giedrius Dubinskas > 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. --14dae9cfc88a7c99b404c74c19d2--