Skip to content

symfony/config does not support multiline text #60317

Closed
@root-aza

Description

@root-aza

Symfony version(s) affected

5.3 - 7.3

Description

The symfony/config component formats phpdoc comments very poorly, and does not support multiple hyphenated text. Example below

How to reproduce

Repoduce stand:

<?php

declare (strict_types = 1);

use Symfony\Component\Config\Builder\ConfigBuilderGenerator;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;

require_once __DIR__.'/vendor/autoload.php';

final class Configuration implements ConfigurationInterface
{
    public function getConfigTreeBuilder(): TreeBuilder
    {
        $treeBuilder = new TreeBuilder('temporal');

        $treeBuilder->getRootNode()
            ->children()
                ->scalarNode('foo')
                    ->defaultValue('bar')
                    ->info(
                        <<<STRING
                          Sets the rate limiting on number of activities that can be
                          executed per second per worker. This can be used to limit resources used by the worker.

                          Notice that the number is represented in float, so that you can set it
                          to less than 1 if needed. For example, set the number to 0.1 means you
                          want your activity to be executed once for every 10 seconds. This can be
                          used to protect down stream services from flooding.
                        STRING
                    )
                ->end()
            ->end()
        ;

        return $treeBuilder;
    }
}


$builder = new ConfigBuilderGenerator(__DIR__ . '/dump');

$builder->build(new Configuration);

Output:

<?php

namespace Symfony\Config;

use Symfony\Component\Config\Loader\ParamConfigurator;
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;

/**
 * This class is automatically generated to help in creating a config.
 */
class TemporalConfig implements \Symfony\Component\Config\Builder\ConfigBuilderInterface
{
    private $foo;
    private $_usedProperties = [];

    /**
     *   Sets the rate limiting on number of activities that can be
      executed per second per worker. This can be used to limit resources used by the worker.

      Notice that the number is represented in float, so that you can set it
      to less than 1 if needed. For example, set the number to 0.1 means you
      want your activity to be executed once for every 10 seconds. This can be
      used to protect down stream services from flooding.
     * @default 'bar'
     * @param ParamConfigurator|mixed $value
     * @return $this
     */
    public function foo($value): static
    {
        $this->_usedProperties['foo'] = true;
        $this->foo = $value;

        return $this;
    }

    public function getExtensionAlias(): string
    {
        return 'temporal';
    }

    public function __construct(array $value = [])
    {
        if (array_key_exists('foo', $value)) {
            $this->_usedProperties['foo'] = true;
            $this->foo = $value['foo'];
            unset($value['foo']);
        }

        if ([] !== $value) {
            throw new InvalidConfigurationException(sprintf('The following keys are not supported by "%s": ', __CLASS__).implode(', ', array_keys($value)));
        }
    }

    public function toArray(): array
    {
        $output = [];
        if (isset($this->_usedProperties['foo'])) {
            $output['foo'] = $this->foo;
        }

        return $output;
    }

}

Possible Solution

No response

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions