diff --git a/src/Symfony/Component/Config/Definition/ReferenceDumper.php b/src/Symfony/Component/Config/Definition/ReferenceDumper.php index 3230c019311c2..ef2b05d10f38c 100644 --- a/src/Symfony/Component/Config/Definition/ReferenceDumper.php +++ b/src/Symfony/Component/Config/Definition/ReferenceDumper.php @@ -115,10 +115,12 @@ private function writeNode(NodeInterface $node, $depth = 0) $default = (string) $default != '' ? ' '.$default : ''; $comments = count($comments) ? '# '.implode(', ', $comments) : ''; - $text = sprintf('%-20s %s %s', $node->getName().':', $default, $comments); + $text = rtrim(sprintf('%-20s %s %s', $node->getName() . ':', $default, $comments), ' '); if ($info = $node->getInfo()) { $this->writeLine(''); + // indenting multi-line info + $info = str_replace("\n", sprintf("\n%" . $depth * 4 . "s# ", ' '), $info); $this->writeLine('# '.$info, $depth * 4); } diff --git a/src/Symfony/Component/Config/Tests/Definition/ReferenceDumperTest.php b/src/Symfony/Component/Config/Tests/Definition/ReferenceDumperTest.php new file mode 100644 index 0000000000000..137caf8cbc37b --- /dev/null +++ b/src/Symfony/Component/Config/Tests/Definition/ReferenceDumperTest.php @@ -0,0 +1,62 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Config\Tests\Definition; + +use Symfony\Component\Config\Definition\ReferenceDumper; +use Symfony\Component\Config\Tests\Fixtures\Configuration\ExampleConfiguration; + +class ReferenceDumperTest extends \PHPUnit_Framework_TestCase +{ + public function testDumper() + { + $configuration = new ExampleConfiguration(); + + $dumper = new ReferenceDumper(); + $this->assertEquals($this->getConfigurationAsString(), $dumper->dump($configuration)); + } + + private function getConfigurationAsString() + { + return << + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Config\Tests\Fixtures\Configuration; + +use Symfony\Component\Config\Definition\Builder\TreeBuilder; +use Symfony\Component\Config\Definition\ConfigurationInterface; + +class ExampleConfiguration implements ConfigurationInterface +{ + public function getConfigTreeBuilder() + { + $treeBuilder = new TreeBuilder(); + $rootNode = $treeBuilder->root('root'); + + $rootNode + ->children() + ->booleanNode('boolean')->defaultTrue()->end() + ->scalarNode('scalar_empty')->end() + ->scalarNode('scalar_null')->defaultNull()->end() + ->scalarNode('scalar_true')->defaultTrue()->end() + ->scalarNode('scalar_false')->defaultFalse()->end() + ->scalarNode('scalar_default')->defaultValue('default')->end() + ->scalarNode('scalar_array_empty')->defaultValue(array())->end() + ->scalarNode('scalar_array_defaults')->defaultValue(array('elem1', 'elem2'))->end() + ->arrayNode('array') + ->info('some info') + ->canBeUnset() + ->children() + ->scalarNode('child1')->end() + ->scalarNode('child2')->end() + ->scalarNode('child3') + ->info( + "this is a long\n". + "multi-line info text\n". + "which should be indented" + ) + ->example('example setting') + ->end() + ->end() + ->end() + ->arrayNode('array_prototype') + ->children() + ->arrayNode('parameters') + ->useAttributeAsKey('name') + ->prototype('array') + ->children() + ->scalarNode('value')->isRequired()->end() + ->end() + ->end() + ->end() + ->end() + ->end() + ->end() + ; + + return $treeBuilder; + } +} pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy