diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services9.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services9.yml index cda41b2cce031..e84bf57bac49e 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services9.yml +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services9.yml @@ -15,7 +15,7 @@ services: properties: { foo: bar, moo: '@foo.baz', qux: { '%foo%': 'foo is %foo%', foobar: '%foo%' } } calls: - [setBar, ['@bar']] - - [initialize, { }] + - [initialize, []] configurator: sc_configure bar: diff --git a/src/Symfony/Component/DependencyInjection/composer.json b/src/Symfony/Component/DependencyInjection/composer.json index 9c813a59483eb..b3f55e0ac55c6 100644 --- a/src/Symfony/Component/DependencyInjection/composer.json +++ b/src/Symfony/Component/DependencyInjection/composer.json @@ -19,7 +19,7 @@ "php": ">=5.3.3" }, "require-dev": { - "symfony/yaml": "~2.1", + "symfony/yaml": "~2.3", "symfony/config": "~2.2" }, "suggest": { diff --git a/src/Symfony/Component/Yaml/Inline.php b/src/Symfony/Component/Yaml/Inline.php index ca419e0565088..b6369658ce814 100644 --- a/src/Symfony/Component/Yaml/Inline.php +++ b/src/Symfony/Component/Yaml/Inline.php @@ -156,9 +156,14 @@ public static function dump($value, $exceptionOnInvalidType = false, $objectSupp */ private static function dumpArray($value, $exceptionOnInvalidType, $objectSupport) { - // array $keys = array_keys($value); $keysCount = count($keys); + + if (0 === $keysCount) { + return '[]'; + } + + // sequence if ((1 === $keysCount && '0' == $keys[0]) || ($keysCount > 1 && array_reduce($keys, function ($v, $w) { return (int) $v + $w; }, 0) === $keysCount * ($keysCount - 1) / 2) ) { diff --git a/src/Symfony/Component/Yaml/Tests/DumperTest.php b/src/Symfony/Component/Yaml/Tests/DumperTest.php index 0b7c1f8b49bc0..a971fd599fa80 100644 --- a/src/Symfony/Component/Yaml/Tests/DumperTest.php +++ b/src/Symfony/Component/Yaml/Tests/DumperTest.php @@ -57,7 +57,7 @@ public function testSetIndentation() $expected = <<assertEquals($expected, $this->dumper->dump($this->array, -10), '->dump() takes an inline level argument'); - $this->assertEquals($expected, $this->dumper->dump($this->array, 0), '->dump() takes an inline level argument'); + $levels = (array) $levels; - $expected = <<assertEquals($expected, $this->dumper->dump($this->array, $level), '->dump() takes an inline level argument'); + } + } + + public function getInlineLevelTests() + { + return array( + array(<<assertEquals($expected, $this->dumper->dump($this->array, 1), '->dump() takes an inline level argument'); - - $expected = <<assertEquals($expected, $this->dumper->dump($this->array, 2), '->dump() takes an inline level argument'); - - $expected = <<assertEquals($expected, $this->dumper->dump($this->array, 3), '->dump() takes an inline level argument'); - - $expected = <<assertEquals($expected, $this->dumper->dump($this->array, 4), '->dump() takes an inline level argument'); - $this->assertEquals($expected, $this->dumper->dump($this->array, 10), '->dump() takes an inline level argument'); +EOF + , array(4, 10)), + ); } public function testObjectSupportEnabled() diff --git a/src/Symfony/Component/Yaml/Tests/InlineTest.php b/src/Symfony/Component/Yaml/Tests/InlineTest.php index dbb12f2834133..bdaef3641f1e2 100644 --- a/src/Symfony/Component/Yaml/Tests/InlineTest.php +++ b/src/Symfony/Component/Yaml/Tests/InlineTest.php @@ -278,6 +278,7 @@ protected function getTestsForDump() "'off'" => 'off', // sequences + '[]' => array(), '[foo, bar, false, null, 12]' => array('foo', 'bar', false, null, 12), '[\'foo,bar\', \'foo bar\']' => array('foo,bar', 'foo bar'),