Repository: symfony/symfony
File: src/Symfony/Component/Config/Definition/ArrayShapeGenerator.php (PHP)

Code before:

            $arrayShape .= \sprintf(",%s\n", !$child instanceof ArrayNode ? self::generateInlinePhpDocForNode($child) : '');
        }

        if ($node->shouldIgnoreExtraKeys()) {
            $arrayShape .= str_repeat('    ', $nestingLevel)."...<mixed>\n";
        }

        $arrayShape = $arrayShape.str_repeat('    ', $nestingLevel - 1).'}';

        return implode('|', [...self::getNormalizedTypes($node, ['array', 'any']), $arrayShape]);
    }

    private static function dumpNodeKey(NodeInterface $node, ?ArrayNode $parent = null): string
    {
        $name = $node->getName();
        $quoted = str_starts_with($name, '@')
            || \in_array(strtolower($name), ['int', 'float', 'bool', 'null', 'scalar'], true)
            || strpbrk($name, '\'"');

        if ($quoted) {
            $name = "'".addslashes($name)."'";
        }

        $optional = !$node->isRequired()
            || ($parent instanceof ArrayNode && $parent->shouldPerformDeepMerging());

        return $name.($optional ? '?' : '');
    }

    private static function handleNumericNode(NumericNode $node): string
    {
        // We could use int<%s, %s> but PhpStorm doesn't support it yet
        // $min = $node->getMin() ?? 'min';
        // $max = $node->getMax() ?? 'max';

        if ($node instanceof IntegerNode) {
            return 'int';
        }
        if ($node instanceof FloatNode) {
            return 'float';
        }

        return 'int|float';
    }

    private static function generateInlinePhpDocForNode(BaseNode $node): string
    {
        $comment = '';
        if ($node->isDeprecated()) {
            $comment .= ' // Deprecated: '.$node->getDeprecation($node->getName(), $node->getPath())['message'];

Review comment (suggestion):
we have wide enough screens nowadays ;)
```suggestion
        $optional = !$node->isRequired() || ($parent instanceof ArrayNode && $parent->shouldPerformDeepMerging());
```

Code after:

            $arrayShape .= \sprintf(",%s\n", !$child instanceof ArrayNode ? self::generateInlinePhpDocForNode($child) : '');
        }

        if ($node->shouldIgnoreExtraKeys()) {
            $arrayShape .= str_repeat('    ', $nestingLevel)."...<mixed>\n";
        }

        $arrayShape = $arrayShape.str_repeat('    ', $nestingLevel - 1).'}';

        return implode('|', [...self::getNormalizedTypes($node, ['array', 'any']), $arrayShape]);
    }

    private static function dumpNodeKey(NodeInterface $node, ?ArrayNode $parent = null): string
    {
        $name = $node->getName();
        $quoted = str_starts_with($name, '@')
            || \in_array(strtolower($name), ['int', 'float', 'bool', 'null', 'scalar'], true)
            || strpbrk($name, '\'"');

        if ($quoted) {
            $name = "'".addslashes($name)."'";
        }

        $optional = !$node->isRequired() || ($parent instanceof ArrayNode && $parent->shouldPerformDeepMerging());

        return $name.($optional ? '?' : '');
    }

    private static function handleNumericNode(NumericNode $node): string
    {
        // We could use int<%s, %s> but PhpStorm doesn't support it yet
        // $min = $node->getMin() ?? 'min';
        // $max = $node->getMax() ?? 'max';

        if ($node instanceof IntegerNode) {
            return 'int';
        }
        if ($node instanceof FloatNode) {
            return 'float';
        }

        return 'int|float';
    }

    private static function generateInlinePhpDocForNode(BaseNode $node): string
    {
        $comment = '';
        if ($node->isDeprecated()) {
            $comment .= ' // Deprecated: '.$node->getDeprecation($node->getName(), $node->getPath())['message'];
        }