Re: Generic classes and methods RFC

From: Date: Sat, 12 Sep 2015 05:55:22 +0000
Subject: Re: Generic classes and methods RFC
References: 1 2 3 4 5 6 7 8  Groups: php.internals 
Request: Send a blank email to internals+get-88160@lists.php.net to get a copy of this message
What would prohibit this?
     class Factory<T> {
         public static function makeFoo() {
            return new Foo<T>();
         }
     }
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.
Well, the counter-example would be that without generic methods, thus automatically applying the class instance types to static method, you would enforce that the user has to define them for static method calls which don't require a type at all (helper methods for instance). -- Ben Scholzen http://www.dasprids.de

Attachment: [application/pkcs7-signature] S/MIME Cryptographic Signature smime.p7s
« previous php.internals (#88160) next »