Repository: symfony/symfony
File: src/Symfony/Component/TypeInfo/Tests/TypeResolver/StringTypeResolverTest.php (PHP)

Code before:
                return $this->value;
            }
        }, $typeContext));
    }

    /**
     * @return iterable<array{0: Type, 1: string, 2?: TypeContext}>
     */
    public static function resolveDataProvider(): iterable
    {
        $typeContextFactory = new TypeContextFactory(new StringTypeResolver());

        // callable
        yield [Type::callable(), 'callable(string, int): mixed'];

        // array
        yield [Type::array(Type::bool()), 'bool[]'];
        yield [Type::array(Type::bool()), 'array<bool>'];
        yield [Type::array(Type::bool(), Type::int()), 'array<int, bool>'];
        yield [Type::array(Type::bool(), Type::arrayKey()), 'array<array-key, bool>'];
        yield [Type::array(Type::bool(), Type::arrayKey()), 'array<int|string, bool>'];
        yield [Type::array(Type::bool(), Type::arrayKey()), 'non-empty-array<int|string, bool>'];

        // list
        yield [Type::list(Type::bool()), 'list<bool>'];
        yield [Type::list(Type::bool()), 'list<int, bool>'];
        yield [Type::list(Type::bool()), 'non-empty-list<int, bool>'];

        // array shape
        yield [Type::arrayShape(['foo' => Type::true(), 1 => Type::false()]), 'array{foo: true, 1: false}'];
        yield [Type::arrayShape(['foo' => ['type' => Type::bool(), 'optional' => true]]), 'array{foo?: bool}'];
        yield [Type::arrayShape(['foo' => Type::bool()], sealed: false), 'array{foo: bool, ...}'];
        yield [Type::arrayShape(['foo' => Type::bool()], extraKeyType: Type::int(), extraValueType: Type::string()), 'array{foo: bool, ...<int, string>}'];
        yield [Type::arrayShape(['foo' => Type::bool()], extraValueType: Type::int()), 'array{foo: bool, ...<int>}'];
        yield [Type::arrayShape(['foo' => Type::union(Type::bool(), Type::float(), Type::int(), Type::null(), Type::string()), 'bar' => Type::string()]), 'array{foo: scalar|null, bar: string}'];

        // object shape
        yield [Type::object(), 'object{foo: true, bar: false}'];

        // this
        yield [Type::object(Dummy::class), '$this', $typeContextFactory->createFromClassName(Dummy::class, AbstractDummy::class)];

        // const
        yield [Type::array(), 'array[1, 2, 3]'];
        yield [Type::false(), 'false'];
        yield [Type::float(), '1.23'];
        yield [Type::int(), '1'];
        yield [Type::null(), 'null'];
        yield [Type::string(), '"string"'];
        yield [Type::true(), 'true'];


Review comment (suggestion):
The `list` generic type only accepts one value. This should not work.

Code after:
            {
                return $this->value;
            }
        }, $typeContext));
    }

    /**
     * @return iterable<array{0: Type, 1: string, 2?: TypeContext}>
     */
    public static function resolveDataProvider(): iterable
    {
        $typeContextFactory = new TypeContextFactory(new StringTypeResolver());

        // callable
        yield [Type::callable(), 'callable(string, int): mixed'];

        // array
        yield [Type::array(Type::bool()), 'bool[]'];
        yield [Type::array(Type::bool()), 'array<bool>'];
        yield [Type::array(Type::bool(), Type::int()), 'array<int, bool>'];
        yield [Type::array(Type::bool(), Type::arrayKey()), 'array<array-key, bool>'];
        yield [Type::array(Type::bool(), Type::arrayKey()), 'array<int|string, bool>'];
        yield [Type::array(Type::bool(), Type::arrayKey()), 'non-empty-array<int|string, bool>'];

        // list
        yield [Type::list(Type::bool()), 'list<bool>'];
        yield [Type::list(Type::bool()), 'non-empty-list<bool>'];

        // array shape
        yield [Type::arrayShape(['foo' => Type::true(), 1 => Type::false()]), 'array{foo: true, 1: false}'];
        yield [Type::arrayShape(['foo' => ['type' => Type::bool(), 'optional' => true]]), 'array{foo?: bool}'];
        yield [Type::arrayShape(['foo' => Type::bool()], sealed: false), 'array{foo: bool, ...}'];
        yield [Type::arrayShape(['foo' => Type::bool()], extraKeyType: Type::int(), extraValueType: Type::string()), 'array{foo: bool, ...<int, string>}'];
        yield [Type::arrayShape(['foo' => Type::bool()], extraValueType: Type::int()), 'array{foo: bool, ...<int>}'];
        yield [Type::arrayShape(['foo' => Type::union(Type::bool(), Type::float(), Type::int(), Type::null(), Type::string()), 'bar' => Type::string()]), 'array{foo: scalar|null, bar: string}'];

        // object shape
        yield [Type::object(), 'object{foo: true, bar: false}'];

        // this
        yield [Type::object(Dummy::class), '$this', $typeContextFactory->createFromClassName(Dummy::class, AbstractDummy::class)];

        // const
        yield [Type::array(), 'array[1, 2, 3]'];
        yield [Type::false(), 'false'];
        yield [Type::float(), '1.23'];
        yield [Type::int(), '1'];
        yield [Type::null(), 'null'];
        yield [Type::string(), '"string"'];
        yield [Type::true(), 'true'];