--TEST-- Generics extension: generic type parameters on class declaration and instantiation --DESCRIPTION-- Tests that generic type parameters on class declarations (class Thing {}) and on object instantiation (new Thing()) are correctly erased before parsing, allowing the code to execute without parse errors. --SKIPIF-- --FILE-- name = $name; } } class Thing { private array $items = []; public function add(mixed $item): void { $this->items[] = $item; } public function count(): int { return count($this->items); } public function first(): mixed { return $this->items[0] ?? null; } } // Generic type on instantiation should be erased $thing = new Thing(); $thing->add(new Widget('foo')); $thing->add(new Widget('bar')); echo $thing->count() . "\n"; echo $thing->first()->name . "\n"; // Verify it is a plain Thing instance at runtime (type is erased) echo ($thing instanceof Thing ? 'true' : 'false') . "\n"; echo get_class($thing) . "\n"; ?> --EXPECT-- 2 foo true Thing