Re: [Pre-RFC] Associated Types

From: Date: Wed, 23 Apr 2025 17:20:56 +0000
Subject: Re: [Pre-RFC] Associated Types
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-127176@lists.php.net to get a copy of this message
On 22 April 2025 14:37:48 BST, "Gina P. Banyard" <internals@gpb.moe> wrote: >Having talked with Arnaud off-list, it seems that using the "usual" generic syntax of >(assuming our parser can cope with it): >``` >interface I<T : int|string> { > public function foo(T $param): T; >} >class CS implements I<string> { > public function foo(string $param): string { > return $param . '!'; > } >} >``` >is possible and would not conflict with any future proposal for generics. I think if this works, it would be a really great step towards generics, where some use cases would be possible, and some would have easier work arounds than today. Possibly we could slowly add places the syntax is allowed, where we can make it make sense without tackling the tricky parts like variance/inheritance and type inference. Rowan Tommins [IMSoP]

« previous php.internals (#127176) next »