@@ -63,7 +63,7 @@ public static function initialize($flags, $parsedLineNumber = null, $parsedFilen
63
63
*
64
64
* @throws ParseException
65
65
*/
66
- public static function parse ($ value , $ flags = 0 , $ references = array () )
66
+ public static function parse ($ value , $ flags = 0 , $ references = [] )
67
67
{
68
68
if (\is_bool ($ flags )) {
69
69
@trigger_error ('Passing a boolean flag to toggle exception handling is deprecated since Symfony 3.1 and will be removed in 4.0. Use the Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE flag instead. ' , E_USER_DEPRECATED );
@@ -93,7 +93,7 @@ public static function parse($value, $flags = 0, $references = array())
93
93
if (\func_num_args () >= 5 ) {
94
94
$ references = func_get_arg (4 );
95
95
} else {
96
- $ references = array () ;
96
+ $ references = [] ;
97
97
}
98
98
}
99
99
@@ -285,7 +285,7 @@ private static function dumpArray($value, $flags)
285
285
{
286
286
// array
287
287
if (($ value || Yaml::DUMP_EMPTY_ARRAY_AS_SEQUENCE & $ flags ) && !self ::isHash ($ value )) {
288
- $ output = array () ;
288
+ $ output = [] ;
289
289
foreach ($ value as $ val ) {
290
290
$ output [] = self ::dump ($ val , $ flags );
291
291
}
@@ -294,7 +294,7 @@ private static function dumpArray($value, $flags)
294
294
}
295
295
296
296
// hash
297
- $ output = array () ;
297
+ $ output = [] ;
298
298
foreach ($ value as $ key => $ val ) {
299
299
$ output [] = sprintf ('%s: %s ' , self ::dump ($ key , $ flags ), self ::dump ($ val , $ flags ));
300
300
}
@@ -318,9 +318,9 @@ private static function dumpArray($value, $flags)
318
318
*
319
319
* @internal
320
320
*/
321
- public static function parseScalar ($ scalar , $ flags = 0 , $ delimiters = null , &$ i = 0 , $ evaluate = true , $ references = array () , $ legacyOmittedKeySupport = false )
321
+ public static function parseScalar ($ scalar , $ flags = 0 , $ delimiters = null , &$ i = 0 , $ evaluate = true , $ references = [] , $ legacyOmittedKeySupport = false )
322
322
{
323
- if (\in_array ($ scalar [$ i ], array ( '" ' , "' " ) )) {
323
+ if (\in_array ($ scalar [$ i ], [ '" ' , "' " ] )) {
324
324
// quoted scalar
325
325
$ output = self ::parseQuotedScalar ($ scalar , $ i );
326
326
@@ -409,9 +409,9 @@ private static function parseQuotedScalar($scalar, &$i)
409
409
*
410
410
* @throws ParseException When malformed inline YAML string is parsed
411
411
*/
412
- private static function parseSequence ($ sequence , $ flags , &$ i = 0 , $ references = array () )
412
+ private static function parseSequence ($ sequence , $ flags , &$ i = 0 , $ references = [] )
413
413
{
414
- $ output = array () ;
414
+ $ output = [] ;
415
415
$ len = \strlen ($ sequence );
416
416
++$ i ;
417
417
@@ -437,8 +437,8 @@ private static function parseSequence($sequence, $flags, &$i = 0, $references =
437
437
$ value = self ::parseMapping ($ sequence , $ flags , $ i , $ references );
438
438
break ;
439
439
default :
440
- $ isQuoted = \in_array ($ sequence [$ i ], array ( '" ' , "' " ) );
441
- $ value = self ::parseScalar ($ sequence , $ flags , array ( ', ' , '] ' ) , $ i , null === $ tag , $ references );
440
+ $ isQuoted = \in_array ($ sequence [$ i ], [ '" ' , "' " ] );
441
+ $ value = self ::parseScalar ($ sequence , $ flags , [ ', ' , '] ' ] , $ i , null === $ tag , $ references );
442
442
443
443
// the value can be an array if a reference has been resolved to an array var
444
444
if (\is_string ($ value ) && !$ isQuoted && false !== strpos ($ value , ': ' )) {
@@ -478,9 +478,9 @@ private static function parseSequence($sequence, $flags, &$i = 0, $references =
478
478
*
479
479
* @throws ParseException When malformed inline YAML string is parsed
480
480
*/
481
- private static function parseMapping ($ mapping , $ flags , &$ i = 0 , $ references = array () )
481
+ private static function parseMapping ($ mapping , $ flags , &$ i = 0 , $ references = [] )
482
482
{
483
- $ output = array () ;
483
+ $ output = [] ;
484
484
$ len = \strlen ($ mapping );
485
485
++$ i ;
486
486
$ allowOverwrite = false ;
@@ -501,8 +501,8 @@ private static function parseMapping($mapping, $flags, &$i = 0, $references = ar
501
501
}
502
502
503
503
// key
504
- $ isKeyQuoted = \in_array ($ mapping [$ i ], array ( '" ' , "' " ) , true );
505
- $ key = self ::parseScalar ($ mapping , $ flags , array ( ': ' , ' ' ) , $ i , false , array () , true );
504
+ $ isKeyQuoted = \in_array ($ mapping [$ i ], [ '" ' , "' " ] , true );
505
+ $ key = self ::parseScalar ($ mapping , $ flags , [ ': ' , ' ' ] , $ i , false , [] , true );
506
506
507
507
if (': ' !== $ key && false === $ i = strpos ($ mapping , ': ' , $ i )) {
508
508
break ;
@@ -520,7 +520,7 @@ private static function parseMapping($mapping, $flags, &$i = 0, $references = ar
520
520
}
521
521
}
522
522
523
- if (': ' !== $ key && !$ isKeyQuoted && (!isset ($ mapping [$ i + 1 ]) || !\in_array ($ mapping [$ i + 1 ], array ( ' ' , ', ' , '[ ' , '] ' , '{ ' , '} ' ) , true ))) {
523
+ if (': ' !== $ key && !$ isKeyQuoted && (!isset ($ mapping [$ i + 1 ]) || !\in_array ($ mapping [$ i + 1 ], [ ' ' , ', ' , '[ ' , '] ' , '{ ' , '} ' ] , true ))) {
524
524
@trigger_error (self ::getDeprecationMessage ('Using a colon after an unquoted mapping key that is not followed by an indication character (i.e. " ", ",", "[", "]", "{", "}") is deprecated since Symfony 3.2 and will throw a ParseException in 4.0. ' ), E_USER_DEPRECATED );
525
525
}
526
526
@@ -578,7 +578,7 @@ private static function parseMapping($mapping, $flags, &$i = 0, $references = ar
578
578
}
579
579
break ;
580
580
default :
581
- $ value = self ::parseScalar ($ mapping , $ flags , array ( ', ' , '} ' ) , $ i , null === $ tag , $ references );
581
+ $ value = self ::parseScalar ($ mapping , $ flags , [ ', ' , '} ' ] , $ i , null === $ tag , $ references );
582
582
// Spec: Keys MUST be unique; first one wins.
583
583
// Parser cannot abort this mapping earlier, since lines
584
584
// are processed sequentially.
@@ -616,7 +616,7 @@ private static function parseMapping($mapping, $flags, &$i = 0, $references = ar
616
616
*
617
617
* @throws ParseException when object parsing support was disabled and the parser detected a PHP object or when a reference could not be resolved
618
618
*/
619
- private static function evaluateScalar ($ scalar , $ flags , $ references = array () )
619
+ private static function evaluateScalar ($ scalar , $ flags , $ references = [] )
620
620
{
621
621
$ scalar = trim ($ scalar );
622
622
$ scalarLower = strtolower ($ scalar );
@@ -766,7 +766,7 @@ private static function evaluateScalar($scalar, $flags, $references = array())
766
766
@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 );
767
767
}
768
768
769
- return (float ) str_replace (array ( ', ' , '_ ' ) , '' , $ scalar );
769
+ return (float ) str_replace ([ ', ' , '_ ' ] , '' , $ scalar );
770
770
case Parser::preg_match (self ::getTimestampRegex (), $ scalar ):
771
771
if (Yaml::PARSE_DATETIME & $ flags ) {
772
772
// When no timezone is provided in the parsed date, YAML spec says we must assume UTC.
@@ -805,7 +805,7 @@ private static function parseTag($value, &$i, $flags)
805
805
$ nextOffset += strspn ($ value , ' ' , $ nextOffset );
806
806
807
807
// Is followed by a scalar
808
- if ((!isset ($ value [$ nextOffset ]) || !\in_array ($ value [$ nextOffset ], array ( '[ ' , '{ ' ) , true )) && 'tagged ' !== $ tag ) {
808
+ if ((!isset ($ value [$ nextOffset ]) || !\in_array ($ value [$ nextOffset ], [ '[ ' , '{ ' ] , true )) && 'tagged ' !== $ tag ) {
809
809
// Manage non-whitelisted scalars in {@link self::evaluateScalar()}
810
810
return ;
811
811
}
0 commit comments