diff --git a/src/Symfony/Component/Yaml/Dumper.php b/src/Symfony/Component/Yaml/Dumper.php index 5b0baa5271..f8d50d7d78 100644 --- a/src/Symfony/Component/Yaml/Dumper.php +++ b/src/Symfony/Component/Yaml/Dumper.php @@ -40,13 +40,13 @@ class Dumper * * @param mixed $input The PHP value * @param integer $inline The level where you switch to inline YAML + * @param integer $indent The level of indentation (used internally) * @param Boolean $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise * @param Boolean $objectSupport true if object support is enabled, false otherwise - * @param integer $indent The level of indentation (used internally) * * @return string The YAML representation of the PHP value */ - public function dump($input, $inline = 0, $exceptionOnInvalidType = false, $objectSupport = false, $indent = 0) + public function dump($input, $inline = 0, $indent = 0, $exceptionOnInvalidType = false, $objectSupport = false) { $output = ''; $prefix = $indent ? str_repeat(' ', $indent) : ''; @@ -63,7 +63,7 @@ class Dumper $prefix, $isAHash ? Inline::dump($key, $exceptionOnInvalidType, $objectSupport).':' : '-', $willBeInlined ? ' ' : "\n", - $this->dump($value, $inline - 1, $exceptionOnInvalidType, $objectSupport, $willBeInlined ? 0 : $indent + $this->indentation) + $this->dump($value, $inline - 1, $willBeInlined ? 0 : $indent + $this->indentation, $exceptionOnInvalidType, $objectSupport) ).($willBeInlined ? "\n" : ''); } } diff --git a/src/Symfony/Component/Yaml/Yaml.php b/src/Symfony/Component/Yaml/Yaml.php index 48a0191d20..768451d8e8 100644 --- a/src/Symfony/Component/Yaml/Yaml.php +++ b/src/Symfony/Component/Yaml/Yaml.php @@ -150,6 +150,6 @@ class Yaml $yaml = new Dumper(); $yaml->setIndentation($indent); - return $yaml->dump($array, $inline, $exceptionOnInvalidType, $objectSupport); + return $yaml->dump($array, $inline, 0, $exceptionOnInvalidType, $objectSupport); } } diff --git a/tests/Symfony/Tests/Component/Yaml/DumperTest.php b/tests/Symfony/Tests/Component/Yaml/DumperTest.php index 83e08ca8cb..9be4aebc14 100644 --- a/tests/Symfony/Tests/Component/Yaml/DumperTest.php +++ b/tests/Symfony/Tests/Component/Yaml/DumperTest.php @@ -154,7 +154,7 @@ EOF; public function testObjectSupportEnabled() { - $dump = $this->dumper->dump(array('foo' => new A(), 'bar' => 1), 0, false, true); + $dump = $this->dumper->dump(array('foo' => new A(), 'bar' => 1), 0, 0, false, true); $this->assertEquals('{ foo: !!php/object:O:30:"Symfony\Tests\Component\Yaml\A":1:{s:1:"a";s:3:"foo";}, bar: 1 }', $dump, '->dump() is able to dump objects'); } @@ -171,7 +171,7 @@ EOF; */ public function testObjectSupportDisabledWithExceptions() { - $this->dumper->dump(array('foo' => new A(), 'bar' => 1), 0, true, false); + $this->dumper->dump(array('foo' => new A(), 'bar' => 1), 0, 0, true, false); } }