Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:62197 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 75310 invoked from network); 15 Aug 2012 17:07:37 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Aug 2012 17:07:37 -0000 Authentication-Results: pb1.pair.com header.from=d.giedrius@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=d.giedrius@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.160.170 as permitted sender) X-PHP-List-Original-Sender: d.giedrius@gmail.com X-Host-Fingerprint: 209.85.160.170 mail-gh0-f170.google.com Received: from [209.85.160.170] ([209.85.160.170:54965] helo=mail-gh0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 76/10-08779-957DB205 for ; Wed, 15 Aug 2012 13:07:37 -0400 Received: by ghbg24 with SMTP id g24so2215029ghb.29 for ; Wed, 15 Aug 2012 10:07:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=3jxGPBgYBEhL45fQN85vdffIpJbjYmrKUjUHEPG0PUo=; b=K8UYE23bV0F8eqj/AxmiH7+ry3YuFzjjfMoOdbVNWbT1ZOXlNg7XDoXQlyMy21N9h6 Bk3+AGICoeuF7hpCBsjIIv8TbvAW3YudHfDVF3HFELbZdVY5IB5FWhHozJ28v4QKVO85 QWXvYSR2AXu9yCYVBQ/sqH724vb7N7usUIGcC9BO4W39h0fKPrTURluDwva4UeFpjnMS CPvBbh7pxeskmNp+9lyAnqIGkDr5aLeXkf8R/A9szUEnrUsKvBK0TBGC77/pYy25fkgd Dn3JwKrNUm0so9JJ+NctYzUYCouW7Y3aiOOBx4wK2xfhqoH03et1AJei6TdiJUYrF/nl srdg== MIME-Version: 1.0 Received: by 10.50.220.194 with SMTP id py2mr19572508igc.15.1345050454497; Wed, 15 Aug 2012 10:07:34 -0700 (PDT) Received: by 10.64.136.45 with HTTP; Wed, 15 Aug 2012 10:07:34 -0700 (PDT) In-Reply-To: <502BC62D.8000405@lsces.co.uk> References: <502BC62D.8000405@lsces.co.uk> Date: Wed, 15 Aug 2012 20:07:34 +0300 Message-ID: To: Lester Caine Cc: PHP internals Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [PHP-DEV] Proposal: use SomeClass::staticMethod From: d.giedrius@gmail.com (Giedrius Dubinskas) On Wed, Aug 15, 2012 at 6:54 PM, Lester Caine wrote: > Giedrius Dubinskas wrote: >> >> My main aim with this suggestion is readability. I'd like to remove >> unnecessary noise in code where it doesn't add any value to the >> reader. Code is easy to type (especially with good autocompletion) but >> it is read more often then typed and I think that is important. Or is >> it just me? > > > Depends who is doing the reading? Since a static method should be provided > with all the data it needs to produce a result, does it actually matter what > it is called and how it is called? Of cause it does when one is trying to > find the right descendent method of the class? > > I've already been told that the code I'm working on upgrading is archaic but > it works fine. The bulk of the recent work has been pulling $this out of > functions and creating a static section for many that handles the results of > building a hash from the object, or supplying a ready built one. I'm told > that it's bad practice to include the static functions within the class? But > they are an integral part of processing the object, or are overridden by > functions in the descendant objects. So 'staticMethod' has to be the right > one for the object created, and SomeClass:: depends on the object being > created. So how does the proposal cope with that type of structure? Sorry, I'm not sure I follow. Would it be possible provide some examples of what you mean? My proposal does not change anything to existing code. It only adds to readability where it is most desired. I picked PHPUnit example just to show that there is a desire for it in real world applications and in that particular case looks like inheritance was used (IMHO incorrectly) to reduce noise of prefixing class to each static method call for assertion and mocking matcher. With my proposal it would be posible to reduce this noise even more. I am not saying that this feature would be used everywhere nor that it should. But it would add a lot where it is already most desired. And FWIW for PHPUnit it would work out of the box. The static methods are already there. One would just need to ``use`` them :-) -- Giedrius Dubinskas