Re: [Initial Feedback] Typed Arrays
| From: | radar3301 | Date: | Wed, 26 Jun 2024 23:08:12 +0000 |
| Subject: | Re: [Initial Feedback] Typed Arrays | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-123902@lists.php.net to get a copy of this message | ||
Several people said:
> generics
Is there a reason why traits can't be used to introduce generics?
i.e. extending the code that composes the trait into the class to
replace the generic type? eg. in
zend_add_trait_method?
(I couldn't quickly find where trait properties get added, even
though my example is for properties.)
trait GenericTrait<T>
{
private ?T $object = null;
}
class ComposableClass
{
use GenericTrait<Foo>;
}
// Result:
class ComposedClass
{
private ?Foo $object = null;
}
Just a random thought...
Regards,
radar3301