Repository: symfony/symfony
File: src/Symfony/Component/PropertyInfo/Util/PhpDocTypeHelper.php (PHP)

Code before:
            return new LegacyType(LegacyType::BUILTIN_TYPE_ARRAY, $nullable, null, true, null, null);
        }

        return new LegacyType($phpType, $nullable, $class);
    }

    /**
     * Creates a {@see Type} from a PHPDoc type.
     */
    private function createType(DocType $docType): ?Type
    {
        $docTypeString = (string) $docType;

        if ('mixed[]' === $docTypeString) {
            $docTypeString = 'array';
        }

        if ($docType instanceof Generic) {
            $fqsen = $docType->getFqsen();

            [$phpType, $class] = $this->getPhpTypeAndClass((string) $fqsen);

            $collection = is_a($class, \Traversable::class, true) || is_a($class, \ArrayAccess::class, true);

            // it's safer to fall back to other extractors if the generic type is too abstract
            if (!$collection && !class_exists($class) && !interface_exists($class)) {
                return null;
            }

            $genericTypes = $docType->getTypes();
            $type = null !== $class ? Type::object($class) : Type::builtin($phpType);

            if ($collection) {
                if (null === $valueType = $genericTypes[1] ?? null) {
                    $keyType = null;
                    $valueType = $genericTypes[0] ?? null;
                } else {
                    $keyType = $genericTypes[0] ?? null;
                }

                $value = $valueType ? $this->getType($valueType) : null;
                $key = $keyType ? $this->getType($keyType) : null;

                return Type::collection($type, $value, $key);
            }

            $variableTypes = array_map(fn ($t) => $this->getType($t), $genericTypes);

            return Type::generic($type, ...array_filter($variableTypes));
        }


Review comment (suggestion):
```suggestion
            if (!$collection && !class_exists($class, false) && !interface_exists($class, false)) {
```

Code after:
            return new LegacyType(LegacyType::BUILTIN_TYPE_ARRAY, $nullable, null, true, null, null);
        }

        return new LegacyType($phpType, $nullable, $class);
    }

    /**
     * Creates a {@see Type} from a PHPDoc type.
     */
    private function createType(DocType $docType): ?Type
    {
        $docTypeString = (string) $docType;

        if ('mixed[]' === $docTypeString) {
            $docTypeString = 'array';
        }

        if ($docType instanceof Generic) {
            $fqsen = $docType->getFqsen();

            [$phpType, $class] = $this->getPhpTypeAndClass((string) $fqsen);

            $collection = is_a($class, \Traversable::class, true) || is_a($class, \ArrayAccess::class, true);

            // it's safer to fall back to other extractors if the generic type is too abstract
            if (!$collection && !class_exists($class, false) && !interface_exists($class, false)) {
                return null;
            }

            $genericTypes = $docType->getTypes();
            $type = null !== $class ? Type::object($class) : Type::builtin($phpType);

            if ($collection) {
                if (null === $valueType = $genericTypes[1] ?? null) {
                    $keyType = null;
                    $valueType = $genericTypes[0] ?? null;
                } else {
                    $keyType = $genericTypes[0] ?? null;
                }

                $value = $valueType ? $this->getType($valueType) : null;
                $key = $keyType ? $this->getType($keyType) : null;

                return Type::collection($type, $value, $key);
            }

            $variableTypes = array_map(fn ($t) => $this->getType($t), $genericTypes);

            return Type::generic($type, ...array_filter($variableTypes));
        }