- Add generic support for method parameters
use Sagittaracc\PhpPythonDecorator\Decorator;
use Sagittaracc\PhpPythonDecorator\modules\generics\aliases\T;
use Sagittaracc\PhpPythonDecorator\modules\validation\core\validators\ArrayOf;
#[T]
class Box
{
use Decorator;
#[ArrayOf(T::class)]
public $items;
public function addItem(#[T] $item)
{
$this->items[] = $item;
}
}
$box = new Box();
$box(Pen::class); // new Box<Pen>();
call_decorator_func_array([$box, 'addItem'], [new Pencil]); // throws a GenericError