Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:88164 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 5097 invoked from network); 12 Sep 2015 14:57:51 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Sep 2015 14:57:51 -0000 X-Host-Fingerprint: 176.25.177.255 unknown Received: from [176.25.177.255] ([176.25.177.255:29696] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C3/D6-37684-E6D34F55 for ; Sat, 12 Sep 2015 10:57:50 -0400 Message-ID: To: internals@lists.php.net References: <55E4B9AA.9060906@dasprids.de> <55F20B8D.3010805@dennis.birkholz.biz> <55F20E72.6050309@dasprids.de> Date: Sat, 12 Sep 2015 15:57:44 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:38.0) Gecko/20100101 Firefox/38.0 SeaMonkey/2.35 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Posted-By: 176.25.177.255 Subject: Re: [PHP-DEV] Generic classes and methods RFC From: ajf@ajf.me (Andrea Faulds) Hey, Levi Morrison wrote: > On Thu, Sep 10, 2015 at 5:12 PM, Ben Scholzen 'DASPRiD' > wrote: >> Hi Dennis, >> >> thanks for your feedback, see my answers below: >> >>> 1. static methods: >>> >>> class Foo { >>> public static function test() { >>> } >>> } >>> >>> how can I call the method: >>> a) Foo::test() >>> or >>> b) Foo::test() >>> >>> in case b), would the generic methods not be a duplication? >> >> >> Case a) is correct here. A static method is not in the context of an >> instance, so it doesn't know about the class boxing by itself. > > I think b would be correct. Can you explain this rationale a bit more? > I'm with Levi here, I think type parameters should matter for static methods. An example might be a list class: class List { // ... public static function newFromConcat(List $a, List $b) { // creates a new list which is two lists concatenated } // ... } In this context, the static method, which operates on instances of list, would benefit from type checking. PHP's dynamic nature means that it wouldn't be the end of the world if static methods couldn't use the type parameter, though. You'd just lose proper type checking. Thanks. -- Andrea Faulds http://ajf.me/