Repository: symfony/symfony
File: src/Symfony/Component/Config/Builder/ConfigBuilderGenerator.php (PHP)

Code before:
                    'PROPERTY' => $property->getName(),
                    'TYPE' => $this->getParamType($prototypeParameterTypes, true),
                    'VAR' => '' === $key ? 'key' : $key,
                    'VALUE' => 'value' === $key ? 'data' : 'value',
                ]);
            }

            return;
        }

        $childClass = new ClassBuilder($namespace, $name);
        if ($prototype instanceof ArrayNode) {
            $childClass->setAllowExtraKeys($prototype->shouldIgnoreExtraKeys());
        }
        $class->addRequire($childClass);
        $this->classes[] = $childClass;

        $property = $class->addProperty(
            $node->getName(),
            $this->getType($childClass->getFqcn().'[]', $hasNormalizationClosures)
        );

        $paramType = $this->getParamType($noKey ? $nodeParameterTypes : $prototypeParameterTypes);

        $comment = $this->getComment($node);
        if ($hasNormalizationClosures && $paramType !== 'array') {
            $comment = sprintf(" * @template TValue of %s\n * @param TValue \$value\n%s", $paramType, $comment);
            $comment .= sprintf(' * @return %s|$this'."\n", $childClass->getFqcn());
            $comment .= sprintf(' * @psalm-return (TValue is array ? %s : static)'."\n ", $childClass->getFqcn());
        }
        if ('' !== $comment) {
            $comment = "/**\n$comment*/\n";
        }

        if ($noKey) {
            $body = $hasNormalizationClosures && $paramType !== 'array' ? '
COMMENTpublic function NAME(PARAM_TYPE $value = []): CLASS|static
{
    $this->_usedProperties[\'PROPERTY\'] = true;
    if (!\is_array($value)) {
        $this->PROPERTY[] = $value;

        return $this;
    }

    return $this->PROPERTY[] = new CLASS($value);
}' : '
COMMENTpublic function NAME(array $value = []): CLASS
{
    $this->_usedProperties[\'PROPERTY\'] = true;


Review comment (suggestion):
```suggestion
        if ($hasNormalizationClosures && 'array' !== $paramType) {
```

Code after:
                    'PROPERTY' => $property->getName(),
                    'TYPE' => $this->getParamType($prototypeParameterTypes, true),
                    'VAR' => '' === $key ? 'key' : $key,
                    'VALUE' => 'value' === $key ? 'data' : 'value',
                ]);
            }

            return;
        }

        $childClass = new ClassBuilder($namespace, $name);
        if ($prototype instanceof ArrayNode) {
            $childClass->setAllowExtraKeys($prototype->shouldIgnoreExtraKeys());
        }
        $class->addRequire($childClass);
        $this->classes[] = $childClass;

        $property = $class->addProperty(
            $node->getName(),
            $this->getType($childClass->getFqcn().'[]', $hasNormalizationClosures)
        );

        $paramType = $this->getParamType($noKey ? $nodeParameterTypes : $prototypeParameterTypes);

        $comment = $this->getComment($node);
<<<<<<< HEAD
        if ($hasNormalizationClosures) {
            $comment = \sprintf(" * @template TValue\n * @param TValue \$value\n%s", $comment);
            $comment .= \sprintf(' * @return %s|$this'."\n", $childClass->getFqcn());
            $comment .= \sprintf(' * @psalm-return (TValue is array ? %s : static)'."\n ", $childClass->getFqcn());
=======
        if ($hasNormalizationClosures && 'array' !== $paramType) {
            $comment = sprintf(" * @template TValue of %s\n * @param TValue \$value\n%s", $paramType, $comment);
            $comment .= sprintf(' * @return %s|$this'."\n", $childClass->getFqcn());
            $comment .= sprintf(' * @psalm-return (TValue is array ? %s : static)'."\n ", $childClass->getFqcn());
>>>>>>> 100c683018d ([Config] Do not generate unreachable configuration paths)
        }
        if ('' !== $comment) {
            $comment = "/**\n$comment*/\n";
        }

        if ($noKey) {
            $body = $hasNormalizationClosures && 'array' !== $paramType ? '
COMMENTpublic function NAME(PARAM_TYPE $value = []): CLASS|static
{
    $this->_usedProperties[\'PROPERTY\'] = true;
    if (!\is_array($value)) {
        $this->PROPERTY[] = $value;

        return $this;
    }