@@ -215,7 +215,7 @@ |
||
215 | 215 | } |
216 | 216 | |
217 | 217 | if ($int < -128 || $int > 255) { |
218 | - return (string) $int; |
|
218 | + return (string)$int; |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | if ($int < 0) { |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | { |
43 | 43 | $this->parser = new Parser(); |
44 | 44 | $this->dumper = new Dumper(); |
45 | - $this->path = __DIR__.'/Fixtures'; |
|
45 | + $this->path = __DIR__ . '/Fixtures'; |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | protected function tearDown() |
@@ -109,9 +109,9 @@ discard block |
||
109 | 109 | |
110 | 110 | public function testSpecifications() |
111 | 111 | { |
112 | - $files = $this->parser->parse(file_get_contents($this->path.'/index.yml')); |
|
112 | + $files = $this->parser->parse(file_get_contents($this->path . '/index.yml')); |
|
113 | 113 | foreach ($files as $file) { |
114 | - $yamls = file_get_contents($this->path.'/'.$file.'.yml'); |
|
114 | + $yamls = file_get_contents($this->path . '/' . $file . '.yml'); |
|
115 | 115 | |
116 | 116 | // split YAMLs documents |
117 | 117 | foreach (preg_split('/^---( %YAML\:1\.0)?/m', $yamls) as $yaml) { |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | } elseif (isset($test['todo']) && $test['todo']) { |
126 | 126 | // TODO |
127 | 127 | } else { |
128 | - eval('$expected = '.trim($test['php']).';'); |
|
128 | + eval('$expected = ' . trim($test['php']) . ';'); |
|
129 | 129 | $this->assertSame($expected, $this->parser->parse($this->dumper->dump($expected, 10)), $test['test']); |
130 | 130 | } |
131 | 131 | } |
@@ -300,8 +300,8 @@ discard block |
||
300 | 300 | |
301 | 301 | public function testBinaryDataIsDumpedBase64Encoded() |
302 | 302 | { |
303 | - $binaryData = file_get_contents(__DIR__.'/Fixtures/arrow.gif'); |
|
304 | - $expected = '{ data: !!binary '.base64_encode($binaryData).' }'; |
|
303 | + $binaryData = file_get_contents(__DIR__ . '/Fixtures/arrow.gif'); |
|
304 | + $expected = '{ data: !!binary ' . base64_encode($binaryData) . ' }'; |
|
305 | 305 | |
306 | 306 | $this->assertSame($expected, $this->dumper->dump(['data' => $binaryData])); |
307 | 307 | } |
@@ -584,7 +584,7 @@ discard block |
||
584 | 584 | ], |
585 | 585 | ]; |
586 | 586 | |
587 | - $this->assertSame(file_get_contents(__DIR__.'/Fixtures/multiple_lines_as_literal_block_for_tagged_values.yml'), $this->dumper->dump($data, 2, 0, Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK)); |
|
587 | + $this->assertSame(file_get_contents(__DIR__ . '/Fixtures/multiple_lines_as_literal_block_for_tagged_values.yml'), $this->dumper->dump($data, 2, 0, Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK)); |
|
588 | 588 | } |
589 | 589 | |
590 | 590 | public function testDumpMultiLineStringAsScalarBlock() |
@@ -600,7 +600,7 @@ discard block |
||
600 | 600 | ], |
601 | 601 | ]; |
602 | 602 | |
603 | - $this->assertSame(file_get_contents(__DIR__.'/Fixtures/multiple_lines_as_literal_block.yml'), $this->dumper->dump($data, 2, 0, Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK)); |
|
603 | + $this->assertSame(file_get_contents(__DIR__ . '/Fixtures/multiple_lines_as_literal_block.yml'), $this->dumper->dump($data, 2, 0, Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK)); |
|
604 | 604 | } |
605 | 605 | |
606 | 606 | public function testDumpMultiLineStringAsScalarBlockWhenFirstLineHasLeadingSpace() |
@@ -611,7 +611,7 @@ discard block |
||
611 | 611 | ], |
612 | 612 | ]; |
613 | 613 | |
614 | - $this->assertSame(file_get_contents(__DIR__.'/Fixtures/multiple_lines_as_literal_block_leading_space_in_first_line.yml'), $this->dumper->dump($data, 2, 0, Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK)); |
|
614 | + $this->assertSame(file_get_contents(__DIR__ . '/Fixtures/multiple_lines_as_literal_block_leading_space_in_first_line.yml'), $this->dumper->dump($data, 2, 0, Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK)); |
|
615 | 615 | } |
616 | 616 | |
617 | 617 | public function testCarriageReturnFollowedByNewlineIsMaintainedWhenDumpingAsMultiLineLiteralBlock() |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | */ |
94 | 94 | private function createFile($content) |
95 | 95 | { |
96 | - $filename = tempnam(sys_get_temp_dir().'/framework-yml-lint-test', 'sf-'); |
|
96 | + $filename = tempnam(sys_get_temp_dir() . '/framework-yml-lint-test', 'sf-'); |
|
97 | 97 | file_put_contents($filename, $content); |
98 | 98 | |
99 | 99 | $this->files[] = $filename; |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | protected function setUp() |
117 | 117 | { |
118 | 118 | $this->files = []; |
119 | - @mkdir(sys_get_temp_dir().'/framework-yml-lint-test'); |
|
119 | + @mkdir(sys_get_temp_dir() . '/framework-yml-lint-test'); |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | protected function tearDown() |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | } |
128 | 128 | } |
129 | 129 | |
130 | - @rmdir(sys_get_temp_dir().'/framework-yml-lint-test'); |
|
130 | + @rmdir(sys_get_temp_dir() . '/framework-yml-lint-test'); |
|
131 | 131 | } |
132 | 132 | } |
133 | 133 |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | { |
31 | 31 | $this->parser = null; |
32 | 32 | |
33 | - chmod(__DIR__.'/Fixtures/not_readable.yml', 0644); |
|
33 | + chmod(__DIR__ . '/Fixtures/not_readable.yml', 0644); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | /** |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | $deprecations = []; |
42 | 42 | |
43 | 43 | if ($deprecated) { |
44 | - set_error_handler(function ($type, $msg) use (&$deprecations) { |
|
44 | + set_error_handler(function($type, $msg) use (&$deprecations) { |
|
45 | 45 | if (\E_USER_DEPRECATED !== $type) { |
46 | 46 | restore_error_handler(); |
47 | 47 | |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | $this->fail('YAML files must not contain tabs'); |
116 | 116 | } catch (\Exception $e) { |
117 | 117 | $this->assertInstanceOf('\Exception', $e, 'YAML files must not contain tabs'); |
118 | - $this->assertEquals('A YAML file cannot contain tabs as indentation at line 2 (near "'.strpbrk($yaml, "\t").'").', $e->getMessage(), 'YAML files must not contain tabs'); |
|
118 | + $this->assertEquals('A YAML file cannot contain tabs as indentation at line 2 (near "' . strpbrk($yaml, "\t") . '").', $e->getMessage(), 'YAML files must not contain tabs'); |
|
119 | 119 | } |
120 | 120 | } |
121 | 121 | } |
@@ -1892,9 +1892,9 @@ discard block |
||
1892 | 1892 | $parser = new Parser(); |
1893 | 1893 | |
1894 | 1894 | $tests = []; |
1895 | - $files = $parser->parseFile(__DIR__.'/Fixtures/'.$testsFile); |
|
1895 | + $files = $parser->parseFile(__DIR__ . '/Fixtures/' . $testsFile); |
|
1896 | 1896 | foreach ($files as $file) { |
1897 | - $yamls = file_get_contents(__DIR__.'/Fixtures/'.$file.'.yml'); |
|
1897 | + $yamls = file_get_contents(__DIR__ . '/Fixtures/' . $file . '.yml'); |
|
1898 | 1898 | |
1899 | 1899 | // split YAMLs documents |
1900 | 1900 | foreach (preg_split('/^---( %YAML\:1\.0)?/m', $yamls) as $yaml) { |
@@ -1906,7 +1906,7 @@ discard block |
||
1906 | 1906 | if (isset($test['todo']) && $test['todo']) { |
1907 | 1907 | // TODO |
1908 | 1908 | } else { |
1909 | - eval('$expected = '.trim($test['php']).';'); |
|
1909 | + eval('$expected = ' . trim($test['php']) . ';'); |
|
1910 | 1910 | |
1911 | 1911 | $tests[] = [var_export($expected, true), $test['yaml'], $test['test'], isset($test['deprecated']) ? $test['deprecated'] : false]; |
1912 | 1912 | } |
@@ -2069,19 +2069,19 @@ discard block |
||
2069 | 2069 | bar: ~ |
2070 | 2070 | <<: [*FOO, *BAR] |
2071 | 2071 | YAML; |
2072 | - $expected = (object) [ |
|
2073 | - 'foo' => (object) [ |
|
2072 | + $expected = (object)[ |
|
2073 | + 'foo' => (object)[ |
|
2074 | 2074 | 'bar' => 1, |
2075 | 2075 | ], |
2076 | - 'bar' => (object) [ |
|
2076 | + 'bar' => (object)[ |
|
2077 | 2077 | 'baz' => 2, |
2078 | 2078 | 'bar' => 1, |
2079 | 2079 | ], |
2080 | - 'baz' => (object) [ |
|
2080 | + 'baz' => (object)[ |
|
2081 | 2081 | 'baz_foo' => 3, |
2082 | 2082 | 'baz_bar' => 4, |
2083 | 2083 | ], |
2084 | - 'foobar' => (object) [ |
|
2084 | + 'foobar' => (object)[ |
|
2085 | 2085 | 'bar' => null, |
2086 | 2086 | 'baz' => 2, |
2087 | 2087 | ], |
@@ -2092,21 +2092,21 @@ discard block |
||
2092 | 2092 | |
2093 | 2093 | public function testFilenamesAreParsedAsStringsWithoutFlag() |
2094 | 2094 | { |
2095 | - $file = __DIR__.'/Fixtures/index.yml'; |
|
2095 | + $file = __DIR__ . '/Fixtures/index.yml'; |
|
2096 | 2096 | |
2097 | 2097 | $this->assertSame($file, $this->parser->parse($file)); |
2098 | 2098 | } |
2099 | 2099 | |
2100 | 2100 | public function testParseFile() |
2101 | 2101 | { |
2102 | - $this->assertIsArray($this->parser->parseFile(__DIR__.'/Fixtures/index.yml')); |
|
2102 | + $this->assertIsArray($this->parser->parseFile(__DIR__ . '/Fixtures/index.yml')); |
|
2103 | 2103 | } |
2104 | 2104 | |
2105 | 2105 | public function testParsingNonExistentFilesThrowsException() |
2106 | 2106 | { |
2107 | 2107 | $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); |
2108 | 2108 | $this->expectExceptionMessageMatches('#^File ".+/Fixtures/nonexistent.yml" does not exist\.$#'); |
2109 | - $this->parser->parseFile(__DIR__.'/Fixtures/nonexistent.yml'); |
|
2109 | + $this->parser->parseFile(__DIR__ . '/Fixtures/nonexistent.yml'); |
|
2110 | 2110 | } |
2111 | 2111 | |
2112 | 2112 | public function testParsingNotReadableFilesThrowsException() |
@@ -2121,7 +2121,7 @@ discard block |
||
2121 | 2121 | $this->markTestSkipped('This test will fail if run under superuser'); |
2122 | 2122 | } |
2123 | 2123 | |
2124 | - $file = __DIR__.'/Fixtures/not_readable.yml'; |
|
2124 | + $file = __DIR__ . '/Fixtures/not_readable.yml'; |
|
2125 | 2125 | chmod($file, 0200); |
2126 | 2126 | |
2127 | 2127 | $this->parser->parseFile($file); |
@@ -2167,13 +2167,13 @@ discard block |
||
2167 | 2167 | d: quux |
2168 | 2168 | <<: *quux |
2169 | 2169 | YAML; |
2170 | - $expected = (object) [ |
|
2171 | - 'mergekeyrefdef' => (object) [ |
|
2170 | + $expected = (object)[ |
|
2171 | + 'mergekeyrefdef' => (object)[ |
|
2172 | 2172 | 'a' => 'foo', |
2173 | 2173 | 'b' => 'bar', |
2174 | 2174 | 'c' => 'baz', |
2175 | 2175 | ], |
2176 | - 'mergekeyderef' => (object) [ |
|
2176 | + 'mergekeyderef' => (object)[ |
|
2177 | 2177 | 'd' => 'quux', |
2178 | 2178 | 'b' => 'bar', |
2179 | 2179 | 'c' => 'baz', |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | try { |
131 | 131 | $requiredLocales = ['fr_FR.UTF-8', 'fr_FR.UTF8', 'fr_FR.utf-8', 'fr_FR.utf8', 'French_France.1252']; |
132 | 132 | if (false === setlocale(\LC_NUMERIC, $requiredLocales)) { |
133 | - $this->markTestSkipped('Could not set any of required locales: '.implode(', ', $requiredLocales)); |
|
133 | + $this->markTestSkipped('Could not set any of required locales: ' . implode(', ', $requiredLocales)); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | $this->assertEquals('1.2', Inline::dump(1.2)); |
@@ -471,43 +471,43 @@ discard block |
||
471 | 471 | ['[\'foo,bar\', \'foo bar\']', ['foo,bar', 'foo bar']], |
472 | 472 | |
473 | 473 | // mappings |
474 | - ['{foo: bar,bar: foo,"false": false,"null": null,integer: 12}', (object) ['foo' => 'bar', 'bar' => 'foo', 'false' => false, 'null' => null, 'integer' => 12], Yaml::PARSE_OBJECT_FOR_MAP], |
|
475 | - ['{ foo : bar, bar : foo, "false" : false, "null" : null, integer : 12 }', (object) ['foo' => 'bar', 'bar' => 'foo', 'false' => false, 'null' => null, 'integer' => 12], Yaml::PARSE_OBJECT_FOR_MAP], |
|
476 | - ['{foo: \'bar\', bar: \'foo: bar\'}', (object) ['foo' => 'bar', 'bar' => 'foo: bar']], |
|
477 | - ['{\'foo\': \'bar\', "bar": \'foo: bar\'}', (object) ['foo' => 'bar', 'bar' => 'foo: bar']], |
|
478 | - ['{\'foo\'\'\': \'bar\', "bar\"": \'foo: bar\'}', (object) ['foo\'' => 'bar', 'bar"' => 'foo: bar']], |
|
479 | - ['{\'foo: \': \'bar\', "bar: ": \'foo: bar\'}', (object) ['foo: ' => 'bar', 'bar: ' => 'foo: bar']], |
|
480 | - ['{"foo:bar": "baz"}', (object) ['foo:bar' => 'baz']], |
|
481 | - ['{"foo":"bar"}', (object) ['foo' => 'bar']], |
|
474 | + ['{foo: bar,bar: foo,"false": false,"null": null,integer: 12}', (object)['foo' => 'bar', 'bar' => 'foo', 'false' => false, 'null' => null, 'integer' => 12], Yaml::PARSE_OBJECT_FOR_MAP], |
|
475 | + ['{ foo : bar, bar : foo, "false" : false, "null" : null, integer : 12 }', (object)['foo' => 'bar', 'bar' => 'foo', 'false' => false, 'null' => null, 'integer' => 12], Yaml::PARSE_OBJECT_FOR_MAP], |
|
476 | + ['{foo: \'bar\', bar: \'foo: bar\'}', (object)['foo' => 'bar', 'bar' => 'foo: bar']], |
|
477 | + ['{\'foo\': \'bar\', "bar": \'foo: bar\'}', (object)['foo' => 'bar', 'bar' => 'foo: bar']], |
|
478 | + ['{\'foo\'\'\': \'bar\', "bar\"": \'foo: bar\'}', (object)['foo\'' => 'bar', 'bar"' => 'foo: bar']], |
|
479 | + ['{\'foo: \': \'bar\', "bar: ": \'foo: bar\'}', (object)['foo: ' => 'bar', 'bar: ' => 'foo: bar']], |
|
480 | + ['{"foo:bar": "baz"}', (object)['foo:bar' => 'baz']], |
|
481 | + ['{"foo":"bar"}', (object)['foo' => 'bar']], |
|
482 | 482 | |
483 | 483 | // nested sequences and mappings |
484 | 484 | ['[foo, [bar, foo]]', ['foo', ['bar', 'foo']]], |
485 | - ['[foo, {bar: foo}]', ['foo', (object) ['bar' => 'foo']]], |
|
486 | - ['{ foo: {bar: foo} }', (object) ['foo' => (object) ['bar' => 'foo']]], |
|
487 | - ['{ foo: [bar, foo] }', (object) ['foo' => ['bar', 'foo']]], |
|
485 | + ['[foo, {bar: foo}]', ['foo', (object)['bar' => 'foo']]], |
|
486 | + ['{ foo: {bar: foo} }', (object)['foo' => (object)['bar' => 'foo']]], |
|
487 | + ['{ foo: [bar, foo] }', (object)['foo' => ['bar', 'foo']]], |
|
488 | 488 | |
489 | 489 | ['[ foo, [ bar, foo ] ]', ['foo', ['bar', 'foo']]], |
490 | 490 | |
491 | - ['[{ foo: {bar: foo} }]', [(object) ['foo' => (object) ['bar' => 'foo']]]], |
|
491 | + ['[{ foo: {bar: foo} }]', [(object)['foo' => (object)['bar' => 'foo']]]], |
|
492 | 492 | |
493 | 493 | ['[foo, [bar, [foo, [bar, foo]], foo]]', ['foo', ['bar', ['foo', ['bar', 'foo']], 'foo']]], |
494 | 494 | |
495 | - ['[foo, {bar: foo, foo: [foo, {bar: foo}]}, [foo, {bar: foo}]]', ['foo', (object) ['bar' => 'foo', 'foo' => ['foo', (object) ['bar' => 'foo']]], ['foo', (object) ['bar' => 'foo']]]], |
|
495 | + ['[foo, {bar: foo, foo: [foo, {bar: foo}]}, [foo, {bar: foo}]]', ['foo', (object)['bar' => 'foo', 'foo' => ['foo', (object)['bar' => 'foo']]], ['foo', (object)['bar' => 'foo']]]], |
|
496 | 496 | |
497 | - ['[foo, bar: { foo: bar }]', ['foo', '1' => (object) ['bar' => (object) ['foo' => 'bar']]]], |
|
498 | - ['[foo, \'@foo.baz\', { \'%foo%\': \'foo is %foo%\', bar: \'%foo%\' }, true, \'@service_container\']', ['foo', '@foo.baz', (object) ['%foo%' => 'foo is %foo%', 'bar' => '%foo%'], true, '@service_container']], |
|
497 | + ['[foo, bar: { foo: bar }]', ['foo', '1' => (object)['bar' => (object)['foo' => 'bar']]]], |
|
498 | + ['[foo, \'@foo.baz\', { \'%foo%\': \'foo is %foo%\', bar: \'%foo%\' }, true, \'@service_container\']', ['foo', '@foo.baz', (object)['%foo%' => 'foo is %foo%', 'bar' => '%foo%'], true, '@service_container']], |
|
499 | 499 | |
500 | 500 | ['{}', new \stdClass()], |
501 | - ['{ foo : bar, bar : {} }', (object) ['foo' => 'bar', 'bar' => new \stdClass()]], |
|
502 | - ['{ foo : [], bar : {} }', (object) ['foo' => [], 'bar' => new \stdClass()]], |
|
503 | - ['{foo: \'bar\', bar: {} }', (object) ['foo' => 'bar', 'bar' => new \stdClass()]], |
|
504 | - ['{\'foo\': \'bar\', "bar": {}}', (object) ['foo' => 'bar', 'bar' => new \stdClass()]], |
|
505 | - ['{\'foo\': \'bar\', "bar": \'{}\'}', (object) ['foo' => 'bar', 'bar' => '{}']], |
|
501 | + ['{ foo : bar, bar : {} }', (object)['foo' => 'bar', 'bar' => new \stdClass()]], |
|
502 | + ['{ foo : [], bar : {} }', (object)['foo' => [], 'bar' => new \stdClass()]], |
|
503 | + ['{foo: \'bar\', bar: {} }', (object)['foo' => 'bar', 'bar' => new \stdClass()]], |
|
504 | + ['{\'foo\': \'bar\', "bar": {}}', (object)['foo' => 'bar', 'bar' => new \stdClass()]], |
|
505 | + ['{\'foo\': \'bar\', "bar": \'{}\'}', (object)['foo' => 'bar', 'bar' => '{}']], |
|
506 | 506 | |
507 | 507 | ['[foo, [{}, {}]]', ['foo', [new \stdClass(), new \stdClass()]]], |
508 | 508 | ['[foo, [[], {}]]', ['foo', [[], new \stdClass()]]], |
509 | 509 | ['[foo, [[{}, {}], {}]]', ['foo', [[new \stdClass(), new \stdClass()], new \stdClass()]]], |
510 | - ['[foo, {bar: {}}]', ['foo', '1' => (object) ['bar' => new \stdClass()]]], |
|
510 | + ['[foo, {bar: {}}]', ['foo', '1' => (object)['bar' => new \stdClass()]]], |
|
511 | 511 | ]; |
512 | 512 | } |
513 | 513 | |
@@ -599,7 +599,7 @@ discard block |
||
599 | 599 | $expected->setDate($year, $month, $day); |
600 | 600 | |
601 | 601 | if (\PHP_VERSION_ID >= 70100) { |
602 | - $expected->setTime($hour, $minute, $second, 1000000 * ($second - (int) $second)); |
|
602 | + $expected->setTime($hour, $minute, $second, 1000000*($second - (int)$second)); |
|
603 | 603 | } else { |
604 | 604 | $expected->setTime($hour, $minute, $second); |
605 | 605 | } |
@@ -628,7 +628,7 @@ discard block |
||
628 | 628 | $expected->setTimeZone(new \DateTimeZone('UTC')); |
629 | 629 | $expected->setDate($year, $month, $day); |
630 | 630 | if (\PHP_VERSION_ID >= 70100) { |
631 | - $expected->setTime($hour, $minute, $second, 1000000 * ($second - (int) $second)); |
|
631 | + $expected->setTime($hour, $minute, $second, 1000000*($second - (int)$second)); |
|
632 | 632 | } else { |
633 | 633 | $expected->setTime($hour, $minute, $second); |
634 | 634 | } |
@@ -29,21 +29,21 @@ |
||
29 | 29 | // on the input arrays. This ordering of the characters avoids the use of strtr, |
30 | 30 | // which performs more slowly. |
31 | 31 | private static $escapees = ['\\', '\\\\', '\\"', '"', |
32 | - "\x00", "\x01", "\x02", "\x03", "\x04", "\x05", "\x06", "\x07", |
|
33 | - "\x08", "\x09", "\x0a", "\x0b", "\x0c", "\x0d", "\x0e", "\x0f", |
|
34 | - "\x10", "\x11", "\x12", "\x13", "\x14", "\x15", "\x16", "\x17", |
|
35 | - "\x18", "\x19", "\x1a", "\x1b", "\x1c", "\x1d", "\x1e", "\x1f", |
|
36 | - "\x7f", |
|
37 | - "\xc2\x85", "\xc2\xa0", "\xe2\x80\xa8", "\xe2\x80\xa9", |
|
38 | - ]; |
|
32 | + "\x00", "\x01", "\x02", "\x03", "\x04", "\x05", "\x06", "\x07", |
|
33 | + "\x08", "\x09", "\x0a", "\x0b", "\x0c", "\x0d", "\x0e", "\x0f", |
|
34 | + "\x10", "\x11", "\x12", "\x13", "\x14", "\x15", "\x16", "\x17", |
|
35 | + "\x18", "\x19", "\x1a", "\x1b", "\x1c", "\x1d", "\x1e", "\x1f", |
|
36 | + "\x7f", |
|
37 | + "\xc2\x85", "\xc2\xa0", "\xe2\x80\xa8", "\xe2\x80\xa9", |
|
38 | + ]; |
|
39 | 39 | private static $escaped = ['\\\\', '\\"', '\\\\', '\\"', |
40 | - '\\0', '\\x01', '\\x02', '\\x03', '\\x04', '\\x05', '\\x06', '\\a', |
|
41 | - '\\b', '\\t', '\\n', '\\v', '\\f', '\\r', '\\x0e', '\\x0f', |
|
42 | - '\\x10', '\\x11', '\\x12', '\\x13', '\\x14', '\\x15', '\\x16', '\\x17', |
|
43 | - '\\x18', '\\x19', '\\x1a', '\\e', '\\x1c', '\\x1d', '\\x1e', '\\x1f', |
|
44 | - '\\x7f', |
|
45 | - '\\N', '\\_', '\\L', '\\P', |
|
46 | - ]; |
|
40 | + '\\0', '\\x01', '\\x02', '\\x03', '\\x04', '\\x05', '\\x06', '\\a', |
|
41 | + '\\b', '\\t', '\\n', '\\v', '\\f', '\\r', '\\x0e', '\\x0f', |
|
42 | + '\\x10', '\\x11', '\\x12', '\\x13', '\\x14', '\\x15', '\\x16', '\\x17', |
|
43 | + '\\x18', '\\x19', '\\x1a', '\\e', '\\x1c', '\\x1d', '\\x1e', '\\x1f', |
|
44 | + '\\x7f', |
|
45 | + '\\N', '\\_', '\\L', '\\P', |
|
46 | + ]; |
|
47 | 47 | |
48 | 48 | /** |
49 | 49 | * Determines if a PHP value would require double quoting in YAML. |
@@ -29,18 +29,18 @@ discard block |
||
29 | 29 | // on the input arrays. This ordering of the characters avoids the use of strtr, |
30 | 30 | // which performs more slowly. |
31 | 31 | private static $escapees = ['\\', '\\\\', '\\"', '"', |
32 | - "\x00", "\x01", "\x02", "\x03", "\x04", "\x05", "\x06", "\x07", |
|
33 | - "\x08", "\x09", "\x0a", "\x0b", "\x0c", "\x0d", "\x0e", "\x0f", |
|
34 | - "\x10", "\x11", "\x12", "\x13", "\x14", "\x15", "\x16", "\x17", |
|
35 | - "\x18", "\x19", "\x1a", "\x1b", "\x1c", "\x1d", "\x1e", "\x1f", |
|
32 | + "\x00", "\x01", "\x02", "\x03", "\x04", "\x05", "\x06", "\x07", |
|
33 | + "\x08", "\x09", "\x0a", "\x0b", "\x0c", "\x0d", "\x0e", "\x0f", |
|
34 | + "\x10", "\x11", "\x12", "\x13", "\x14", "\x15", "\x16", "\x17", |
|
35 | + "\x18", "\x19", "\x1a", "\x1b", "\x1c", "\x1d", "\x1e", "\x1f", |
|
36 | 36 | "\x7f", |
37 | 37 | "\xc2\x85", "\xc2\xa0", "\xe2\x80\xa8", "\xe2\x80\xa9", |
38 | 38 | ]; |
39 | 39 | private static $escaped = ['\\\\', '\\"', '\\\\', '\\"', |
40 | - '\\0', '\\x01', '\\x02', '\\x03', '\\x04', '\\x05', '\\x06', '\\a', |
|
41 | - '\\b', '\\t', '\\n', '\\v', '\\f', '\\r', '\\x0e', '\\x0f', |
|
40 | + '\\0', '\\x01', '\\x02', '\\x03', '\\x04', '\\x05', '\\x06', '\\a', |
|
41 | + '\\b', '\\t', '\\n', '\\v', '\\f', '\\r', '\\x0e', '\\x0f', |
|
42 | 42 | '\\x10', '\\x11', '\\x12', '\\x13', '\\x14', '\\x15', '\\x16', '\\x17', |
43 | - '\\x18', '\\x19', '\\x1a', '\\e', '\\x1c', '\\x1d', '\\x1e', '\\x1f', |
|
43 | + '\\x18', '\\x19', '\\x1a', '\\e', '\\x1c', '\\x1d', '\\x1e', '\\x1f', |
|
44 | 44 | '\\x7f', |
45 | 45 | '\\N', '\\_', '\\L', '\\P', |
46 | 46 | ]; |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | */ |
55 | 55 | public static function requiresDoubleQuoting($value) |
56 | 56 | { |
57 | - return 0 < preg_match('/'.self::REGEX_CHARACTER_TO_ESCAPE.'/u', $value); |
|
57 | + return 0 < preg_match('/' . self::REGEX_CHARACTER_TO_ESCAPE . '/u', $value); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | $e = null; |
134 | 134 | $data = null; |
135 | 135 | |
136 | - if (2 /* MB_OVERLOAD_STRING */ & (int) ini_get('mbstring.func_overload')) { |
|
136 | + if (2 /* MB_OVERLOAD_STRING */ & (int)ini_get('mbstring.func_overload')) { |
|
137 | 137 | $mbEncoding = mb_internal_encoding(); |
138 | 138 | mb_internal_encoding('UTF-8'); |
139 | 139 | } |
@@ -235,13 +235,13 @@ discard block |
||
235 | 235 | isset($values['leadspaces']) |
236 | 236 | && ( |
237 | 237 | '!' === $values['value'][0] |
238 | - || self::preg_match('#^(?P<key>'.Inline::REGEX_QUOTED_STRING.'|[^ \'"\{\[].*?) *\:(\s+(?P<value>.+?))?\s*$#u', $this->trimTag($values['value']), $matches) |
|
238 | + || self::preg_match('#^(?P<key>' . Inline::REGEX_QUOTED_STRING . '|[^ \'"\{\[].*?) *\:(\s+(?P<value>.+?))?\s*$#u', $this->trimTag($values['value']), $matches) |
|
239 | 239 | ) |
240 | 240 | ) { |
241 | 241 | // this is a compact notation element, add to next block and parse |
242 | 242 | $block = $values['value']; |
243 | 243 | if ($this->isNextLineIndented()) { |
244 | - $block .= "\n".$this->getNextEmbedBlock($this->getCurrentLineIndentation() + \strlen($values['leadspaces']) + 1); |
|
244 | + $block .= "\n" . $this->getNextEmbedBlock($this->getCurrentLineIndentation() + \strlen($values['leadspaces']) + 1); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | $data[] = $this->parseBlock($this->getRealCurrentLineNb(), $block, $flags); |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | array_pop($this->refsBeingParsed); |
255 | 255 | } |
256 | 256 | } elseif ( |
257 | - self::preg_match('#^(?P<key>(?:![^\s]++\s++)?(?:'.Inline::REGEX_QUOTED_STRING.'|(?:!?!php/const:)?[^ \'"\[\{!].*?)) *\:(\s++(?P<value>.+))?$#u', rtrim($this->currentLine), $values) |
|
257 | + self::preg_match('#^(?P<key>(?:![^\s]++\s++)?(?:' . Inline::REGEX_QUOTED_STRING . '|(?:!?!php/const:)?[^ \'"\[\{!].*?)) *\:(\s++(?P<value>.+))?$#u', rtrim($this->currentLine), $values) |
|
258 | 258 | && (false === strpos($values['key'], ' #') || \in_array($values['key'][0], ['"', "'"])) |
259 | 259 | ) { |
260 | 260 | if ($context && 'sequence' == $context) { |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | |
287 | 287 | // Convert float keys to strings, to avoid being converted to integers by PHP |
288 | 288 | if (\is_float($key)) { |
289 | - $key = (string) $key; |
|
289 | + $key = (string)$key; |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | if ('<<' === $key && (!isset($values['value']) || !self::preg_match('#^&(?P<ref>[^ ]+)#u', $values['value'], $refMatches))) { |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | $refValue = $this->refs[$refName]; |
306 | 306 | |
307 | 307 | if (Yaml::PARSE_OBJECT_FOR_MAP & $flags && $refValue instanceof \stdClass) { |
308 | - $refValue = (array) $refValue; |
|
308 | + $refValue = (array)$refValue; |
|
309 | 309 | } |
310 | 310 | |
311 | 311 | if (!\is_array($refValue)) { |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | $parsed = $this->parseBlock($this->getRealCurrentLineNb() + 1, $value, $flags); |
323 | 323 | |
324 | 324 | if (Yaml::PARSE_OBJECT_FOR_MAP & $flags && $parsed instanceof \stdClass) { |
325 | - $parsed = (array) $parsed; |
|
325 | + $parsed = (array)$parsed; |
|
326 | 326 | } |
327 | 327 | |
328 | 328 | if (!\is_array($parsed)) { |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | // in the sequence override keys specified in later mapping nodes. |
336 | 336 | foreach ($parsed as $parsedItem) { |
337 | 337 | if (Yaml::PARSE_OBJECT_FOR_MAP & $flags && $parsedItem instanceof \stdClass) { |
338 | - $parsedItem = (array) $parsedItem; |
|
338 | + $parsedItem = (array)$parsedItem; |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | if (!\is_array($parsedItem)) { |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | $this->refs[$refMatches['ref']] = $value; |
381 | 381 | |
382 | 382 | if (Yaml::PARSE_OBJECT_FOR_MAP & $flags && $value instanceof \stdClass) { |
383 | - $value = (array) $value; |
|
383 | + $value = (array)$value; |
|
384 | 384 | } |
385 | 385 | |
386 | 386 | $data += $value; |
@@ -723,10 +723,10 @@ discard block |
||
723 | 723 | return $this->refs[$value]; |
724 | 724 | } |
725 | 725 | |
726 | - if (self::preg_match('/^(?:'.self::TAG_PATTERN.' +)?'.self::BLOCK_SCALAR_HEADER_PATTERN.'$/', $value, $matches)) { |
|
726 | + if (self::preg_match('/^(?:' . self::TAG_PATTERN . ' +)?' . self::BLOCK_SCALAR_HEADER_PATTERN . '$/', $value, $matches)) { |
|
727 | 727 | $modifiers = isset($matches['modifiers']) ? $matches['modifiers'] : ''; |
728 | 728 | |
729 | - $data = $this->parseBlockScalar($matches['separator'], preg_replace('#\d+#', '', $modifiers), abs((int) $modifiers)); |
|
729 | + $data = $this->parseBlockScalar($matches['separator'], preg_replace('#\d+#', '', $modifiers), abs((int)$modifiers)); |
|
730 | 730 | |
731 | 731 | if ('' !== $matches['tag']) { |
732 | 732 | if ('!!binary' === $matches['tag']) { |
@@ -745,7 +745,7 @@ discard block |
||
745 | 745 | $quotation = '' !== $value && ('"' === $value[0] || "'" === $value[0]) ? $value[0] : null; |
746 | 746 | |
747 | 747 | // do not take following lines into account when the current line is a quoted single line value |
748 | - if (null !== $quotation && self::preg_match('/^'.$quotation.'.*'.$quotation.'(\s*#.*)?$/', $value)) { |
|
748 | + if (null !== $quotation && self::preg_match('/^' . $quotation . '.*' . $quotation . '(\s*#.*)?$/', $value)) { |
|
749 | 749 | return Inline::parse($value, $flags, $this->refs); |
750 | 750 | } |
751 | 751 | |
@@ -776,7 +776,7 @@ discard block |
||
776 | 776 | $value .= $lines[$i]; |
777 | 777 | $previousLineBlank = false; |
778 | 778 | } else { |
779 | - $value .= ' '.$lines[$i]; |
|
779 | + $value .= ' ' . $lines[$i]; |
|
780 | 780 | $previousLineBlank = false; |
781 | 781 | } |
782 | 782 | } |
@@ -878,11 +878,11 @@ discard block |
||
878 | 878 | $previousLineIndented = false; |
879 | 879 | $previousLineBlank = true; |
880 | 880 | } elseif (' ' === $blockLines[$i][0]) { |
881 | - $text .= "\n".$blockLines[$i]; |
|
881 | + $text .= "\n" . $blockLines[$i]; |
|
882 | 882 | $previousLineIndented = true; |
883 | 883 | $previousLineBlank = false; |
884 | 884 | } elseif ($previousLineIndented) { |
885 | - $text .= "\n".$blockLines[$i]; |
|
885 | + $text .= "\n" . $blockLines[$i]; |
|
886 | 886 | $previousLineIndented = false; |
887 | 887 | $previousLineBlank = false; |
888 | 888 | } elseif ($previousLineBlank || 0 === $i) { |
@@ -890,7 +890,7 @@ discard block |
||
890 | 890 | $previousLineIndented = false; |
891 | 891 | $previousLineBlank = false; |
892 | 892 | } else { |
893 | - $text .= ' '.$blockLines[$i]; |
|
893 | + $text .= ' ' . $blockLines[$i]; |
|
894 | 894 | $previousLineIndented = false; |
895 | 895 | $previousLineBlank = false; |
896 | 896 | } |
@@ -1119,7 +1119,7 @@ discard block |
||
1119 | 1119 | */ |
1120 | 1120 | private function getLineTag($value, $flags, $nextLineCheck = true) |
1121 | 1121 | { |
1122 | - if ('' === $value || '!' !== $value[0] || 1 !== self::preg_match('/^'.self::TAG_PATTERN.' *( +#.*)?$/', $value, $matches)) { |
|
1122 | + if ('' === $value || '!' !== $value[0] || 1 !== self::preg_match('/^' . self::TAG_PATTERN . ' *( +#.*)?$/', $value, $matches)) { |
|
1123 | 1123 | return null; |
1124 | 1124 | } |
1125 | 1125 | |
@@ -1146,11 +1146,11 @@ discard block |
||
1146 | 1146 | $message = rtrim($message, '.'); |
1147 | 1147 | |
1148 | 1148 | if (null !== $this->filename) { |
1149 | - $message .= ' in '.$this->filename; |
|
1149 | + $message .= ' in ' . $this->filename; |
|
1150 | 1150 | } |
1151 | 1151 | |
1152 | - $message .= ' on line '.($this->getRealCurrentLineNb() + 1); |
|
1152 | + $message .= ' on line ' . ($this->getRealCurrentLineNb() + 1); |
|
1153 | 1153 | |
1154 | - return $message.'.'; |
|
1154 | + return $message . '.'; |
|
1155 | 1155 | } |
1156 | 1156 | } |
@@ -50,9 +50,9 @@ discard block |
||
50 | 50 | */ |
51 | 51 | public function setIndentation($num) |
52 | 52 | { |
53 | - @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 3.1 and will be removed in 4.0. Pass the indentation to the constructor instead.', \E_USER_DEPRECATED); |
|
53 | + @trigger_error('The ' . __METHOD__ . ' method is deprecated since Symfony 3.1 and will be removed in 4.0. Pass the indentation to the constructor instead.', \E_USER_DEPRECATED); |
|
54 | 54 | |
55 | - $this->indentation = (int) $num; |
|
55 | + $this->indentation = (int)$num; |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
@@ -90,11 +90,11 @@ discard block |
||
90 | 90 | $dumpObjectAsInlineMap = true; |
91 | 91 | |
92 | 92 | if (Yaml::DUMP_OBJECT_AS_MAP & $flags && ($input instanceof \ArrayObject || $input instanceof \stdClass)) { |
93 | - $dumpObjectAsInlineMap = empty((array) $input); |
|
93 | + $dumpObjectAsInlineMap = empty((array)$input); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | if ($inline <= 0 || (!\is_array($input) && !$input instanceof TaggedValue && $dumpObjectAsInlineMap) || empty($input)) { |
97 | - $output .= $prefix.Inline::dump($input, $flags); |
|
97 | + $output .= $prefix . Inline::dump($input, $flags); |
|
98 | 98 | } else { |
99 | 99 | $dumpAsMap = Inline::isHash($input); |
100 | 100 | |
@@ -102,8 +102,8 @@ discard block |
||
102 | 102 | if ($inline >= 1 && Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK & $flags && \is_string($value) && false !== strpos($value, "\n") && false === strpos($value, "\r")) { |
103 | 103 | // If the first line starts with a space character, the spec requires a blockIndicationIndicator |
104 | 104 | // http://www.yaml.org/spec/1.2/spec.html#id2793979 |
105 | - $blockIndentationIndicator = (' ' === substr($value, 0, 1)) ? (string) $this->indentation : ''; |
|
106 | - $output .= sprintf("%s%s%s |%s\n", $prefix, $dumpAsMap ? Inline::dump($key, $flags).':' : '-', '', $blockIndentationIndicator); |
|
105 | + $blockIndentationIndicator = (' ' === substr($value, 0, 1)) ? (string)$this->indentation : ''; |
|
106 | + $output .= sprintf("%s%s%s |%s\n", $prefix, $dumpAsMap ? Inline::dump($key, $flags) . ':' : '-', '', $blockIndentationIndicator); |
|
107 | 107 | |
108 | 108 | foreach (explode("\n", $value) as $row) { |
109 | 109 | $output .= sprintf("%s%s%s\n", $prefix, str_repeat(' ', $this->indentation), $row); |
@@ -113,12 +113,12 @@ discard block |
||
113 | 113 | } |
114 | 114 | |
115 | 115 | if ($value instanceof TaggedValue) { |
116 | - $output .= sprintf('%s%s !%s', $prefix, $dumpAsMap ? Inline::dump($key, $flags).':' : '-', $value->getTag()); |
|
116 | + $output .= sprintf('%s%s !%s', $prefix, $dumpAsMap ? Inline::dump($key, $flags) . ':' : '-', $value->getTag()); |
|
117 | 117 | |
118 | 118 | if ($inline >= 1 && Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK & $flags && \is_string($value->getValue()) && false !== strpos($value->getValue(), "\n") && false === strpos($value->getValue(), "\r\n")) { |
119 | 119 | // If the first line starts with a space character, the spec requires a blockIndicationIndicator |
120 | 120 | // http://www.yaml.org/spec/1.2/spec.html#id2793979 |
121 | - $blockIndentationIndicator = (' ' === substr($value->getValue(), 0, 1)) ? (string) $this->indentation : ''; |
|
121 | + $blockIndentationIndicator = (' ' === substr($value->getValue(), 0, 1)) ? (string)$this->indentation : ''; |
|
122 | 122 | $output .= sprintf(" |%s\n", $blockIndentationIndicator); |
123 | 123 | |
124 | 124 | foreach (explode("\n", $value->getValue()) as $row) { |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | } |
130 | 130 | |
131 | 131 | if ($inline - 1 <= 0 || null === $value->getValue() || is_scalar($value->getValue())) { |
132 | - $output .= ' '.$this->dump($value->getValue(), $inline - 1, 0, $flags)."\n"; |
|
132 | + $output .= ' ' . $this->dump($value->getValue(), $inline - 1, 0, $flags) . "\n"; |
|
133 | 133 | } else { |
134 | 134 | $output .= "\n"; |
135 | 135 | $output .= $this->dump($value->getValue(), $inline - 1, $dumpAsMap ? $indent + $this->indentation : $indent + 2, $flags); |
@@ -141,17 +141,17 @@ discard block |
||
141 | 141 | $dumpObjectAsInlineMap = true; |
142 | 142 | |
143 | 143 | if (Yaml::DUMP_OBJECT_AS_MAP & $flags && ($value instanceof \ArrayObject || $value instanceof \stdClass)) { |
144 | - $dumpObjectAsInlineMap = empty((array) $value); |
|
144 | + $dumpObjectAsInlineMap = empty((array)$value); |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | $willBeInlined = $inline - 1 <= 0 || !\is_array($value) && $dumpObjectAsInlineMap || empty($value); |
148 | 148 | |
149 | 149 | $output .= sprintf('%s%s%s%s', |
150 | 150 | $prefix, |
151 | - $dumpAsMap ? Inline::dump($key, $flags).':' : '-', |
|
151 | + $dumpAsMap ? Inline::dump($key, $flags) . ':' : '-', |
|
152 | 152 | $willBeInlined ? ' ' : "\n", |
153 | 153 | $this->dump($value, $inline - 1, $willBeInlined ? 0 : $indent + $this->indentation, $flags) |
154 | - ).($willBeInlined ? "\n" : ''); |
|
154 | + ) . ($willBeInlined ? "\n" : ''); |
|
155 | 155 | } |
156 | 156 | } |
157 | 157 |
@@ -41,10 +41,10 @@ discard block |
||
41 | 41 | */ |
42 | 42 | public static function initialize($flags, $parsedLineNumber = null, $parsedFilename = null) |
43 | 43 | { |
44 | - self::$exceptionOnInvalidType = (bool) (Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE & $flags); |
|
45 | - self::$objectSupport = (bool) (Yaml::PARSE_OBJECT & $flags); |
|
46 | - self::$objectForMap = (bool) (Yaml::PARSE_OBJECT_FOR_MAP & $flags); |
|
47 | - self::$constantSupport = (bool) (Yaml::PARSE_CONSTANT & $flags); |
|
44 | + self::$exceptionOnInvalidType = (bool)(Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE & $flags); |
|
45 | + self::$objectSupport = (bool)(Yaml::PARSE_OBJECT & $flags); |
|
46 | + self::$objectForMap = (bool)(Yaml::PARSE_OBJECT_FOR_MAP & $flags); |
|
47 | + self::$constantSupport = (bool)(Yaml::PARSE_CONSTANT & $flags); |
|
48 | 48 | self::$parsedFilename = $parsedFilename; |
49 | 49 | |
50 | 50 | if (null !== $parsedLineNumber) { |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | return ''; |
106 | 106 | } |
107 | 107 | |
108 | - if (2 /* MB_OVERLOAD_STRING */ & (int) ini_get('mbstring.func_overload')) { |
|
108 | + if (2 /* MB_OVERLOAD_STRING */ & (int)ini_get('mbstring.func_overload')) { |
|
109 | 109 | $mbEncoding = mb_internal_encoding(); |
110 | 110 | mb_internal_encoding('ASCII'); |
111 | 111 | } |
@@ -184,11 +184,11 @@ discard block |
||
184 | 184 | return $value->format('c'); |
185 | 185 | case \is_object($value): |
186 | 186 | if ($value instanceof TaggedValue) { |
187 | - return '!'.$value->getTag().' '.self::dump($value->getValue(), $flags); |
|
187 | + return '!' . $value->getTag() . ' ' . self::dump($value->getValue(), $flags); |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | if (Yaml::DUMP_OBJECT & $flags) { |
191 | - return '!php/object '.self::dump(serialize($value)); |
|
191 | + return '!php/object ' . self::dump(serialize($value)); |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | if (Yaml::DUMP_OBJECT_AS_MAP & $flags && ($value instanceof \stdClass || $value instanceof \ArrayObject)) { |
@@ -209,22 +209,22 @@ discard block |
||
209 | 209 | case false === $value: |
210 | 210 | return 'false'; |
211 | 211 | case ctype_digit($value): |
212 | - return \is_string($value) ? "'$value'" : (int) $value; |
|
212 | + return \is_string($value) ? "'$value'" : (int)$value; |
|
213 | 213 | case is_numeric($value) && false === strpos($value, "\f") && false === strpos($value, "\n") && false === strpos($value, "\r") && false === strpos($value, "\t") && false === strpos($value, "\v"): |
214 | 214 | $locale = setlocale(\LC_NUMERIC, 0); |
215 | 215 | if (false !== $locale) { |
216 | 216 | setlocale(\LC_NUMERIC, 'C'); |
217 | 217 | } |
218 | 218 | if (\is_float($value)) { |
219 | - $repr = (string) $value; |
|
219 | + $repr = (string)$value; |
|
220 | 220 | if (is_infinite($value)) { |
221 | 221 | $repr = str_ireplace('INF', '.Inf', $repr); |
222 | 222 | } elseif (floor($value) == $value && $repr == $value) { |
223 | 223 | // Preserve float data type since storing a whole number will result in integer value. |
224 | - $repr = '!!float '.$repr; |
|
224 | + $repr = '!!float ' . $repr; |
|
225 | 225 | } |
226 | 226 | } else { |
227 | - $repr = \is_string($value) ? "'$value'" : (string) $value; |
|
227 | + $repr = \is_string($value) ? "'$value'" : (string)$value; |
|
228 | 228 | } |
229 | 229 | if (false !== $locale) { |
230 | 230 | setlocale(\LC_NUMERIC, $locale); |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | case '' == $value: |
235 | 235 | return "''"; |
236 | 236 | case self::isBinaryString($value): |
237 | - return '!!binary '.base64_encode($value); |
|
237 | + return '!!binary ' . base64_encode($value); |
|
238 | 238 | case Escaper::requiresDoubleQuoting($value): |
239 | 239 | return Escaper::escapeWithDoubleQuotes($value); |
240 | 240 | case Escaper::requiresSingleQuoting($value): |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | if (Parser::preg_match('/[ \t]+#/', $output, $match, \PREG_OFFSET_CAPTURE)) { |
344 | 344 | $output = substr($output, 0, $match[0][1]); |
345 | 345 | } |
346 | - } elseif (Parser::preg_match('/^(.'.($legacyOmittedKeySupport ? '+' : '*').'?)('.implode('|', $delimiters).')/', substr($scalar, $i), $match)) { |
|
346 | + } elseif (Parser::preg_match('/^(.' . ($legacyOmittedKeySupport ? '+' : '*') . '?)(' . implode('|', $delimiters) . ')/', substr($scalar, $i), $match)) { |
|
347 | 347 | $output = $match[1]; |
348 | 348 | $i += \strlen($output); |
349 | 349 | } else { |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | */ |
380 | 380 | private static function parseQuotedScalar($scalar, &$i) |
381 | 381 | { |
382 | - if (!Parser::preg_match('/'.self::REGEX_QUOTED_STRING.'/Au', substr($scalar, $i), $match)) { |
|
382 | + if (!Parser::preg_match('/' . self::REGEX_QUOTED_STRING . '/Au', substr($scalar, $i), $match)) { |
|
383 | 383 | throw new ParseException(sprintf('Malformed inline YAML string: "%s".', substr($scalar, $i)), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename); |
384 | 384 | } |
385 | 385 | |
@@ -445,7 +445,7 @@ discard block |
||
445 | 445 | // embedded mapping? |
446 | 446 | try { |
447 | 447 | $pos = 0; |
448 | - $value = self::parseMapping('{'.$value.'}', $flags, $pos, $references); |
|
448 | + $value = self::parseMapping('{' . $value . '}', $flags, $pos, $references); |
|
449 | 449 | } catch (\InvalidArgumentException $e) { |
450 | 450 | // no, it's not |
451 | 451 | } |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | continue 2; |
495 | 495 | case '}': |
496 | 496 | if (self::$objectForMap) { |
497 | - return (object) $output; |
|
497 | + return (object)$output; |
|
498 | 498 | } |
499 | 499 | |
500 | 500 | return $output; |
@@ -664,13 +664,13 @@ discard block |
||
664 | 664 | case 0 === strpos($scalar, '!str'): |
665 | 665 | @trigger_error(self::getDeprecationMessage('Support for the !str tag is deprecated since Symfony 3.4. Use the !!str tag instead.'), \E_USER_DEPRECATED); |
666 | 666 | |
667 | - return (string) substr($scalar, 5); |
|
667 | + return (string)substr($scalar, 5); |
|
668 | 668 | case 0 === strpos($scalar, '!!str '): |
669 | - return (string) substr($scalar, 6); |
|
669 | + return (string)substr($scalar, 6); |
|
670 | 670 | case 0 === strpos($scalar, '! '): |
671 | 671 | @trigger_error(self::getDeprecationMessage('Using the non-specific tag "!" is deprecated since Symfony 3.4 as its behavior will change in 4.0. It will force non-evaluating your values in 4.0. Use plain integers or !!float instead.'), \E_USER_DEPRECATED); |
672 | 672 | |
673 | - return (int) self::parseScalar(substr($scalar, 2), $flags); |
|
673 | + return (int)self::parseScalar(substr($scalar, 2), $flags); |
|
674 | 674 | case 0 === strpos($scalar, '!php/object:'): |
675 | 675 | if (self::$objectSupport) { |
676 | 676 | @trigger_error(self::getDeprecationMessage('The !php/object: tag to indicate dumped PHP objects is deprecated since Symfony 3.4 and will be removed in 4.0. Use the !php/object (without the colon) tag instead.'), \E_USER_DEPRECATED); |
@@ -743,7 +743,7 @@ discard block |
||
743 | 743 | |
744 | 744 | return null; |
745 | 745 | case 0 === strpos($scalar, '!!float '): |
746 | - return (float) substr($scalar, 8); |
|
746 | + return (float)substr($scalar, 8); |
|
747 | 747 | case 0 === strpos($scalar, '!!binary '): |
748 | 748 | return self::evaluateBinaryScalar(substr($scalar, 9)); |
749 | 749 | default: |
@@ -754,7 +754,7 @@ discard block |
||
754 | 754 | // no break |
755 | 755 | case '+' === $scalar[0] || '-' === $scalar[0] || '.' === $scalar[0] || is_numeric($scalar[0]): |
756 | 756 | if (Parser::preg_match('{^[+-]?[0-9][0-9_]*$}', $scalar)) { |
757 | - $scalar = str_replace('_', '', (string) $scalar); |
|
757 | + $scalar = str_replace('_', '', (string)$scalar); |
|
758 | 758 | } |
759 | 759 | |
760 | 760 | switch (true) { |
@@ -763,22 +763,22 @@ discard block |
||
763 | 763 | return octdec($scalar); |
764 | 764 | } |
765 | 765 | |
766 | - $cast = (int) $scalar; |
|
766 | + $cast = (int)$scalar; |
|
767 | 767 | |
768 | - return ($scalar === (string) $cast) ? $cast : $scalar; |
|
768 | + return ($scalar === (string)$cast) ? $cast : $scalar; |
|
769 | 769 | case '-' === $scalar[0] && ctype_digit(substr($scalar, 1)): |
770 | 770 | if (preg_match('/^-0[0-7]+$/', $scalar)) { |
771 | 771 | return -octdec(substr($scalar, 1)); |
772 | 772 | } |
773 | 773 | |
774 | - $cast = (int) $scalar; |
|
774 | + $cast = (int)$scalar; |
|
775 | 775 | |
776 | - return ($scalar === (string) $cast) ? $cast : $scalar; |
|
776 | + return ($scalar === (string)$cast) ? $cast : $scalar; |
|
777 | 777 | case is_numeric($scalar): |
778 | 778 | case Parser::preg_match(self::getHexRegex(), $scalar): |
779 | 779 | $scalar = str_replace('_', '', $scalar); |
780 | 780 | |
781 | - return '0x' === $scalar[0].$scalar[1] ? hexdec($scalar) : (float) $scalar; |
|
781 | + return '0x' === $scalar[0] . $scalar[1] ? hexdec($scalar) : (float)$scalar; |
|
782 | 782 | case '.inf' === $scalarLower: |
783 | 783 | case '.nan' === $scalarLower: |
784 | 784 | return -log(0); |
@@ -790,7 +790,7 @@ discard block |
||
790 | 790 | @trigger_error(self::getDeprecationMessage('Using the comma as a group separator for floats is deprecated since Symfony 3.2 and will be removed in 4.0.'), \E_USER_DEPRECATED); |
791 | 791 | } |
792 | 792 | |
793 | - return (float) str_replace([',', '_'], '', $scalar); |
|
793 | + return (float)str_replace([',', '_'], '', $scalar); |
|
794 | 794 | case Parser::preg_match(self::getTimestampRegex(), $scalar): |
795 | 795 | if (Yaml::PARSE_DATETIME & $flags) { |
796 | 796 | // When no timezone is provided in the parsed date, YAML spec says we must assume UTC. |
@@ -806,7 +806,7 @@ discard block |
||
806 | 806 | } |
807 | 807 | } |
808 | 808 | |
809 | - return (string) $scalar; |
|
809 | + return (string)$scalar; |
|
810 | 810 | } |
811 | 811 | |
812 | 812 | /** |
@@ -859,7 +859,7 @@ discard block |
||
859 | 859 | { |
860 | 860 | $parsedBinaryData = self::parseScalar(preg_replace('/\s/', '', $scalar)); |
861 | 861 | |
862 | - if (0 !== (\strlen($parsedBinaryData) % 4)) { |
|
862 | + if (0 !== (\strlen($parsedBinaryData)%4)) { |
|
863 | 863 | throw new ParseException(sprintf('The normalized base64 encoded data (data without whitespace characters) length must be a multiple of four (%d bytes given).', \strlen($parsedBinaryData)), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename); |
864 | 864 | } |
865 | 865 | |
@@ -915,13 +915,13 @@ discard block |
||
915 | 915 | $message = rtrim($message, '.'); |
916 | 916 | |
917 | 917 | if (null !== self::$parsedFilename) { |
918 | - $message .= ' in '.self::$parsedFilename; |
|
918 | + $message .= ' in ' . self::$parsedFilename; |
|
919 | 919 | } |
920 | 920 | |
921 | 921 | if (-1 !== self::$parsedLineNumber) { |
922 | - $message .= ' on line '.(self::$parsedLineNumber + 1); |
|
922 | + $message .= ' on line ' . (self::$parsedLineNumber + 1); |
|
923 | 923 | } |
924 | 924 | |
925 | - return $message.'.'; |
|
925 | + return $message . '.'; |
|
926 | 926 | } |
927 | 927 | } |