[ 'code' => ' */ public static array $map = []; /** * @template T as Foo * @param class-string $class * @return T */ public function get(string $class) : Foo { if (isset(self::$map[$class])) { return self::$map[$class]; } self::$map[$class] = new $class(); return self::$map[$class]; } }', ], 'basicClassStringMapDifferentTemplateName' => [ 'code' => ' */ public static array $map = []; /** * @template U as Foo * @param class-string $class * @return U */ public function get(string $class) : Foo { if (isset(self::$map[$class])) { return self::$map[$class]; } self::$map[$class] = new $class(); return self::$map[$class]; } }', ], 'noCrashWithSplatMap' => [ 'code' => ' $args */ function takesVariadic(...$args): void { } /** @param class-string-map $arr */ function foo(array $arr) : void { takesVariadic(...$arr); }', ], 'assignClassStringMapInConstruct' => [ 'code' => ' */ private array $map; /** @param class-string-map $map */ public function __construct(array $map) { $this->map = $map; } }', ], 'assignClassStringMapInMethod' => [ 'code' => ' */ private array $map = []; /** @param class-string-map $map */ public function set(array $map): void { $this->map = $map; } }', ], 'simpleSetter' => [ 'code' => ' */ public array $map = []; /** * @template U of object * @param class-string $key * @param U $obj */ public function set(string $key, object $obj): void { $this->map[$key] = $obj; } }' , ], ]; } public function providerInvalidCodeParse(): iterable { return [ 'assignInvalidClass' => [ 'code' => ' */ public static array $map = []; /** * @template T * @param class-string $class */ public function get(string $class) : void { self::$map[$class] = 5; } }', 'error_message' => 'InvalidPropertyAssignmentValue', ], 'assignInvalidClassDifferentTemplateName' => [ 'code' => ' */ public static array $map = []; /** * @template U * @param class-string $class */ public function get(string $class) : void { self::$map[$class] = 5; } }', 'error_message' => 'InvalidPropertyAssignmentValue', ], ]; } }