Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:88159 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 68805 invoked from network); 12 Sep 2015 00:19:26 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Sep 2015 00:19:26 -0000 Authentication-Results: pb1.pair.com header.from=morrison.levi@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=morrison.levi@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.213.50 as permitted sender) X-PHP-List-Original-Sender: morrison.levi@gmail.com X-Host-Fingerprint: 209.85.213.50 mail-vk0-f50.google.com Received: from [209.85.213.50] ([209.85.213.50:34442] helo=mail-vk0-f50.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 6C/E3-37684-C8F63F55 for ; Fri, 11 Sep 2015 20:19:24 -0400 Received: by vkhf67 with SMTP id f67so34276108vkh.1 for ; Fri, 11 Sep 2015 17:19:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=tB0CkzblprdCqe2SKa1ucfNZ4zfhN6RrP1F/L8LZjWo=; b=n3YsMimxIOGVJgAROYIKiQhwFDb8sTlmEwrI63PB1q8Kbfm65VGwbw5NVp3TSuoPP4 KLxCg87RYoexaoDAnCuqObmzYj2USAB4ZN6HcGwiPKyrQa/0P7Nv0XcgOjmOeoWpP/RJ xqQ4ev+liKrq8soF/hOsfxYxKsRocBEjP0yhsOLOBSIP1FREQ+sITUk1PxwZpL60cvOE J2s3Vs5wV6kHPBCE08ez2Gn5ji0oQhiTNBq5mKAHHcV9+xsdM2/lAHGxMkHuvucbt3Nt 1T+sdkMawN6SujPiub5yscAmf+mYZ+KqRCtFHEIEIM5+SOnTwM8nuvlcpXeuwNbWqBNn EzYA== MIME-Version: 1.0 X-Received: by 10.31.8.68 with SMTP id 65mr996652vki.154.1442017161482; Fri, 11 Sep 2015 17:19:21 -0700 (PDT) Sender: morrison.levi@gmail.com Received: by 10.31.41.205 with HTTP; Fri, 11 Sep 2015 17:19:21 -0700 (PDT) In-Reply-To: <55F30791.3080207@dasprids.de> References: <55E4B9AA.9060906@dasprids.de> <55F20B8D.3010805@dennis.birkholz.biz> <55F20E72.6050309@dasprids.de> <55F30791.3080207@dasprids.de> Date: Fri, 11 Sep 2015 18:19:21 -0600 X-Google-Sender-Auth: B2xP5p__dn4-gJmWjRVc-UMvONs Message-ID: To: Ben Scholzen Cc: internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] Generic classes and methods RFC From: levim@php.net (Levi Morrison) (Please stop top-posting!) On Fri, Sep 11, 2015 at 10:55 AM, Ben Scholzen wrote: > Well, with the example, there's a good reason to have them separated: > > class Factory > { > public static function createFoo() > { > return new Foo(); > } > > public static function createBar() > { > return new Bar(); > } > } > > class Foo {} > class Bar {} > > The factory instance does not know to need about , this is purely a type > for the method to be able to create another class, which requires that type. > You couldn't put this definition on the Factory class. What would prohibit this? class Factory { public static function makeFoo() { return new Foo(); } } It's perhaps less generic than what you posted, but this demonstrates that that a Factory *could* hold the definition on the class and not the method. To be honest, I don't know why you would bother doing this anyway. I am a fan of realistic examples and Factories that make Foos of type T is pretty unrealistic.