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

Code before:
                }

                $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));
        }

        if ($docType instanceof Collection) {
            $fqsen = $docType->getFqsen();
            if ($fqsen && 'list' === $fqsen->getName() && !class_exists(List_::class, false) && !class_exists((string) $fqsen)) {
                // Workaround for phpdocumentor/type-resolver < 1.6
                return Type::list($this->getType($docType->getValueType()));
            }

            [$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;
            }

            $type = null !== $class ? Type::object($class) : Type::builtin($phpType);

            if ($collection) {
                $value = $this->getType($docType->getValueType());
                $key = $this->getType($docType->getKeyType());

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

            $variableTypes = [];

            if (null !== $valueType = $this->getType($docType->getValueType())) {
                $variableTypes[] = $valueType;
            }

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

        if (!$docTypeString) {
            return null;
        }


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

Code after:
                }

                $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));
        }

        if ($docType instanceof Collection) {
            $fqsen = $docType->getFqsen();
            if ($fqsen && 'list' === $fqsen->getName() && !class_exists(List_::class, false) && !class_exists((string) $fqsen)) {
                // Workaround for phpdocumentor/type-resolver < 1.6
                return Type::list($this->getType($docType->getValueType()));
            }

            [$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;
            }

            $type = null !== $class ? Type::object($class) : Type::builtin($phpType);

            if ($collection) {
                $value = $this->getType($docType->getValueType());
                $key = $this->getType($docType->getKeyType());

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

            $variableTypes = [];

            if (!$this->hasNoExplicitKeyType($docType) && null !== $keyType = $this->getType($docType->getKeyType())) {
                $variableTypes[] = $keyType;
            }

            if (null !== $valueType = $this->getType($docType->getValueType())) {
                $variableTypes[] = $valueType;
            }

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