Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 020178b

Browse filesBrowse files
committed
[Yaml] remove deprecated features
1 parent d8594de commit 020178b
Copy full SHA for 020178b

12 files changed

+59
-580
lines changed

‎src/Symfony/Component/Yaml/Dumper.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Yaml/Dumper.php
-30Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,6 @@ public function __construct($indentation = 4)
3737
$this->indentation = $indentation;
3838
}
3939

40-
/**
41-
* Sets the indentation.
42-
*
43-
* @param int $num The amount of spaces to use for indentation of nested nodes
44-
*/
45-
public function setIndentation($num)
46-
{
47-
@trigger_error('The '.__METHOD__.' method is deprecated since version 3.1 and will be removed in 4.0. Pass the indentation to the constructor instead.', E_USER_DEPRECATED);
48-
49-
$this->indentation = (int) $num;
50-
}
51-
5240
/**
5341
* Dumps a PHP value to YAML.
5442
*
@@ -61,24 +49,6 @@ public function setIndentation($num)
6149
*/
6250
public function dump($input, $inline = 0, $indent = 0, $flags = 0)
6351
{
64-
if (is_bool($flags)) {
65-
@trigger_error('Passing a boolean flag to toggle exception handling is deprecated since version 3.1 and will be removed in 4.0. Use the Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE flag instead.', E_USER_DEPRECATED);
66-
67-
if ($flags) {
68-
$flags = Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE;
69-
} else {
70-
$flags = 0;
71-
}
72-
}
73-
74-
if (func_num_args() >= 5) {
75-
@trigger_error('Passing a boolean flag to toggle object support is deprecated since version 3.1 and will be removed in 4.0. Use the Yaml::DUMP_OBJECT flag instead.', E_USER_DEPRECATED);
76-
77-
if (func_get_arg(4)) {
78-
$flags |= Yaml::DUMP_OBJECT;
79-
}
80-
}
81-
8252
$output = '';
8353
$prefix = $indent ? str_repeat(' ', $indent) : '';
8454
$dumpObjectAsInlineMap = true;

‎src/Symfony/Component/Yaml/Inline.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Yaml/Inline.php
+13-93Lines changed: 13 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -46,38 +46,6 @@ class Inline
4646
*/
4747
public static function parse($value, $flags = 0, $references = array())
4848
{
49-
if (is_bool($flags)) {
50-
@trigger_error('Passing a boolean flag to toggle exception handling is deprecated since version 3.1 and will be removed in 4.0. Use the Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE flag instead.', E_USER_DEPRECATED);
51-
52-
if ($flags) {
53-
$flags = Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE;
54-
} else {
55-
$flags = 0;
56-
}
57-
}
58-
59-
if (func_num_args() >= 3 && !is_array($references)) {
60-
@trigger_error('Passing a boolean flag to toggle object support is deprecated since version 3.1 and will be removed in 4.0. Use the Yaml::PARSE_OBJECT flag instead.', E_USER_DEPRECATED);
61-
62-
if ($references) {
63-
$flags |= Yaml::PARSE_OBJECT;
64-
}
65-
66-
if (func_num_args() >= 4) {
67-
@trigger_error('Passing a boolean flag to toggle object for map support is deprecated since version 3.1 and will be removed in 4.0. Use the Yaml::PARSE_OBJECT_FOR_MAP flag instead.', E_USER_DEPRECATED);
68-
69-
if (func_get_arg(3)) {
70-
$flags |= Yaml::PARSE_OBJECT_FOR_MAP;
71-
}
72-
}
73-
74-
if (func_num_args() >= 5) {
75-
$references = func_get_arg(4);
76-
} else {
77-
$references = array();
78-
}
79-
}
80-
8149
self::$exceptionOnInvalidType = (bool) (Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE & $flags);
8250
self::$objectSupport = (bool) (Yaml::PARSE_OBJECT & $flags);
8351
self::$objectForMap = (bool) (Yaml::PARSE_OBJECT_FOR_MAP & $flags);
@@ -137,24 +105,6 @@ public static function parse($value, $flags = 0, $references = array())
137105
*/
138106
public static function dump($value, $flags = 0)
139107
{
140-
if (is_bool($flags)) {
141-
@trigger_error('Passing a boolean flag to toggle exception handling is deprecated since version 3.1 and will be removed in 4.0. Use the Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE flag instead.', E_USER_DEPRECATED);
142-
143-
if ($flags) {
144-
$flags = Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE;
145-
} else {
146-
$flags = 0;
147-
}
148-
}
149-
150-
if (func_num_args() >= 3) {
151-
@trigger_error('Passing a boolean flag to toggle object support is deprecated since version 3.1 and will be removed in 4.0. Use the Yaml::DUMP_OBJECT flag instead.', E_USER_DEPRECATED);
152-
153-
if (func_get_arg(2)) {
154-
$flags |= Yaml::DUMP_OBJECT;
155-
}
156-
}
157-
158108
switch (true) {
159109
case is_resource($value):
160110
if (Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE & $flags) {
@@ -330,14 +280,10 @@ public static function parseScalar($scalar, $flags = 0, $delimiters = null, &$i
330280
}
331281

332282
// a non-quoted string cannot start with @ or ` (reserved) nor with a scalar indicator (| or >)
333-
if ($output && ('@' === $output[0] || '`' === $output[0] || '|' === $output[0] || '>' === $output[0])) {
283+
if ($output && ('@' === $output[0] || '`' === $output[0] || '|' === $output[0] || '>' === $output[0] || '%' === $output[0])) {
334284
throw new ParseException(sprintf('The reserved indicator "%s" cannot start a plain scalar; you need to quote the scalar.', $output[0]));
335285
}
336286

337-
if ($output && '%' === $output[0]) {
338-
@trigger_error(sprintf('Not quoting the scalar "%s" starting with the "%%" indicator character is deprecated since Symfony 3.1 and will throw a ParseException in 4.0.', $output), E_USER_DEPRECATED);
339-
}
340-
341287
if ($evaluate) {
342288
$output = self::evaluateScalar($output, $flags, $references);
343289
}
@@ -481,24 +427,20 @@ private static function parseMapping($mapping, $flags, &$i = 0, $references = ar
481427
// key
482428
$key = self::parseScalar($mapping, $flags, array(':', ' '), $i, false, array(), true);
483429

484-
if (':' !== $key && false === $i = strpos($mapping, ':', $i)) {
430+
if (false === $i = strpos($mapping, ':', $i)) {
485431
break;
486432
}
487433

488-
if (':' === $key) {
489-
@trigger_error('Omitting the key of a mapping is deprecated and will throw a ParseException in 4.0.', E_USER_DEPRECATED);
490-
}
491-
492434
if (!(Yaml::PARSE_KEYS_AS_STRINGS & $flags)) {
493435
$evaluatedKey = self::evaluateScalar($key, $flags, $references);
494436

495437
if ('' !== $key && $evaluatedKey !== $key && !is_string($evaluatedKey)) {
496-
@trigger_error('Implicit casting of incompatible mapping keys to strings is deprecated since version 3.3 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0. Pass the PARSE_KEYS_AS_STRING flag to explicitly enable the type casts.', E_USER_DEPRECATED);
438+
throw new ParseException('Non-string mapping keys are not supported. Pass the Yaml::PARSE_KEYS_AS_STRINGS flag to cast them to strings.', self::$parsedLineNumber + 1, $mapping);
497439
}
498440
}
499441

500442
if (':' !== $key && (!isset($mapping[$i + 1]) || !in_array($mapping[$i + 1], array(' ', ',', '[', ']', '{', '}'), true))) {
501-
@trigger_error('Using a colon that is not followed by an indication character (i.e. " ", ",", "[", "]", "{", "}" is deprecated since version 3.2 and will throw a ParseException in 4.0.', E_USER_DEPRECATED);
443+
throw new ParseException('Colons must be followed by a space or an indication character (i.e. " ", ",", "[", "]", "{", "}").', self::$parsedLineNumber + 1, $mapping);
502444
}
503445

504446
while ($i < $len) {
@@ -509,7 +451,6 @@ private static function parseMapping($mapping, $flags, &$i = 0, $references = ar
509451
}
510452

511453
$tag = self::parseTag($mapping, $i, $flags);
512-
$duplicate = false;
513454
switch ($mapping[$i]) {
514455
case '[':
515456
// nested sequence
@@ -518,8 +459,7 @@ private static function parseMapping($mapping, $flags, &$i = 0, $references = ar
518459
// Parser cannot abort this mapping earlier, since lines
519460
// are processed sequentially.
520461
if (isset($output[$key])) {
521-
@trigger_error(sprintf('Duplicate key "%s" detected on line %d whilst parsing YAML. Silent handling of duplicate mapping keys in YAML is deprecated since version 3.2 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0.', $key, self::$parsedLineNumber + 1), E_USER_DEPRECATED);
522-
$duplicate = true;
462+
throw new ParseException(sprintf('Duplicate key "%s" detected.', $key), self::$parsedLineNumber + 1, $mapping);
523463
}
524464
break;
525465
case '{':
@@ -529,8 +469,7 @@ private static function parseMapping($mapping, $flags, &$i = 0, $references = ar
529469
// Parser cannot abort this mapping earlier, since lines
530470
// are processed sequentially.
531471
if (isset($output[$key])) {
532-
@trigger_error(sprintf('Duplicate key "%s" detected on line %d whilst parsing YAML. Silent handling of duplicate mapping keys in YAML is deprecated since version 3.2 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0.', $key, self::$parsedLineNumber + 1), E_USER_DEPRECATED);
533-
$duplicate = true;
472+
throw new ParseException(sprintf('Duplicate key "%s" detected.', $key), self::$parsedLineNumber + 1, $mapping);
534473
}
535474
break;
536475
default:
@@ -539,19 +478,17 @@ private static function parseMapping($mapping, $flags, &$i = 0, $references = ar
539478
// Parser cannot abort this mapping earlier, since lines
540479
// are processed sequentially.
541480
if (isset($output[$key])) {
542-
@trigger_error(sprintf('Duplicate key "%s" detected on line %d whilst parsing YAML. Silent handling of duplicate mapping keys in YAML is deprecated since version 3.2 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0.', $key, self::$parsedLineNumber + 1), E_USER_DEPRECATED);
543-
$duplicate = true;
481+
throw new ParseException(sprintf('Duplicate key "%s" detected.', $key), self::$parsedLineNumber + 1, $mapping);
544482
}
545483
--$i;
546484
}
547485

548-
if (!$duplicate) {
549-
if (null !== $tag) {
550-
$output[$key] = new TaggedValue($tag, $value);
551-
} else {
552-
$output[$key] = $value;
553-
}
486+
if (null !== $tag) {
487+
$output[$key] = new TaggedValue($tag, $value);
488+
} else {
489+
$output[$key] = $value;
554490
}
491+
555492
++$i;
556493

557494
continue 2;
@@ -620,18 +557,6 @@ private static function evaluateScalar($scalar, $flags, $references = array())
620557
throw new ParseException('Object support when parsing a YAML file has been disabled.');
621558
}
622559

623-
return;
624-
case 0 === strpos($scalar, '!!php/object:'):
625-
if (self::$objectSupport) {
626-
@trigger_error('The !!php/object tag to indicate dumped PHP objects is deprecated since version 3.1 and will be removed in 4.0. Use the !php/object tag instead.', E_USER_DEPRECATED);
627-
628-
return unserialize(substr($scalar, 13));
629-
}
630-
631-
if (self::$exceptionOnInvalidType) {
632-
throw new ParseException('Object support when parsing a YAML file has been disabled.');
633-
}
634-
635560
return;
636561
case 0 === strpos($scalar, '!php/const:'):
637562
if (self::$constantSupport) {
@@ -680,13 +605,8 @@ private static function evaluateScalar($scalar, $flags, $references = array())
680605
return -log(0);
681606
case '-.inf' === $scalarLower:
682607
return log(0);
683-
case Parser::preg_match('/^(-|\+)?[0-9][0-9,]*(\.[0-9_]+)?$/', $scalar):
684608
case Parser::preg_match('/^(-|\+)?[0-9][0-9_]*(\.[0-9_]+)?$/', $scalar):
685-
if (false !== strpos($scalar, ',')) {
686-
@trigger_error('Using the comma as a group separator for floats is deprecated since version 3.2 and will be removed in 4.0.', E_USER_DEPRECATED);
687-
}
688-
689-
return (float) str_replace(array(',', '_'), '', $scalar);
609+
return (float) str_replace('_', '', $scalar);
690610
case Parser::preg_match(self::getTimestampRegex(), $scalar):
691611
if (Yaml::PARSE_DATETIME & $flags) {
692612
// When no timezone is provided in the parsed date, YAML spec says we must assume UTC.

‎src/Symfony/Component/Yaml/Parser.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Yaml/Parser.php
+6-47Lines changed: 6 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,6 @@ class Parser
3333
private $skippedLineNumbers = array();
3434
private $locallySkippedLineNumbers = array();
3535

36-
public function __construct()
37-
{
38-
if (func_num_args() > 0) {
39-
@trigger_error(sprintf('The constructor arguments $offset, $totalNumberOfLines, $skippedLineNumbers of %s are deprecated and will be removed in 4.0', self::class), E_USER_DEPRECATED);
40-
41-
$this->offset = func_get_arg(0);
42-
if (func_num_args() > 1) {
43-
$this->totalNumberOfLines = func_get_arg(1);
44-
}
45-
if (func_num_args() > 2) {
46-
$this->skippedLineNumbers = func_get_arg(2);
47-
}
48-
}
49-
}
50-
5136
/**
5237
* Parses a YAML string to a PHP value.
5338
*
@@ -60,32 +45,6 @@ public function __construct()
6045
*/
6146
public function parse($value, $flags = 0)
6247
{
63-
if (is_bool($flags)) {
64-
@trigger_error('Passing a boolean flag to toggle exception handling is deprecated since version 3.1 and will be removed in 4.0. Use the Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE flag instead.', E_USER_DEPRECATED);
65-
66-
if ($flags) {
67-
$flags = Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE;
68-
} else {
69-
$flags = 0;
70-
}
71-
}
72-
73-
if (func_num_args() >= 3) {
74-
@trigger_error('Passing a boolean flag to toggle object support is deprecated since version 3.1 and will be removed in 4.0. Use the Yaml::PARSE_OBJECT flag instead.', E_USER_DEPRECATED);
75-
76-
if (func_get_arg(2)) {
77-
$flags |= Yaml::PARSE_OBJECT;
78-
}
79-
}
80-
81-
if (func_num_args() >= 4) {
82-
@trigger_error('Passing a boolean flag to toggle object for map support is deprecated since version 3.1 and will be removed in 4.0. Use the Yaml::PARSE_OBJECT_FOR_MAP flag instead.', E_USER_DEPRECATED);
83-
84-
if (func_get_arg(3)) {
85-
$flags |= Yaml::PARSE_OBJECT_FOR_MAP;
86-
}
87-
}
88-
8948
if (false === preg_match('//u', $value)) {
9049
throw new ParseException('The YAML value does not appear to be valid UTF-8.');
9150
}
@@ -178,7 +137,7 @@ private function doParse($value, $flags)
178137
}
179138

180139
if (isset($values['value'][1]) && '?' === $values['value'][0] && ' ' === $values['value'][1]) {
181-
@trigger_error('Starting an unquoted string with a question mark followed by a space is deprecated since version 3.3 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0.', E_USER_DEPRECATED);
140+
throw new ParseException('Complex mappings are not supported.', $this->getRealCurrentLineNb() + 1, $this->currentLine);
182141
}
183142

184143
// array
@@ -230,7 +189,7 @@ private function doParse($value, $flags)
230189
}
231190

232191
if (!(Yaml::PARSE_KEYS_AS_STRINGS & $flags) && !is_string($key)) {
233-
@trigger_error('Implicit casting of incompatible mapping keys to strings is deprecated since version 3.3 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0. Pass the PARSE_KEYS_AS_STRING flag to explicitly enable the type casts.', E_USER_DEPRECATED);
192+
throw new ParseException('Non-string mapping keys are not supported. Pass the Yaml::PARSE_KEYS_AS_STRINGS flag to cast them to strings.', $this->getRealCurrentLineNb() + 1, $this->currentLine);
234193
}
235194

236195
// Convert float keys to strings, to avoid being converted to integers by PHP
@@ -304,7 +263,7 @@ private function doParse($value, $flags)
304263
$data[$key] = null;
305264
}
306265
} else {
307-
@trigger_error(sprintf('Duplicate key "%s" detected on line %d whilst parsing YAML. Silent handling of duplicate mapping keys in YAML is deprecated since version 3.2 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0.', $key, $this->getRealCurrentLineNb() + 1), E_USER_DEPRECATED);
266+
throw new ParseException(sprintf('Duplicate key "%s" detected.', $key), $this->getRealCurrentLineNb() + 1, $this->currentLine);
308267
}
309268
} else {
310269
// remember the parsed line number here in case we need it to provide some contexts in error messages below
@@ -319,7 +278,7 @@ private function doParse($value, $flags)
319278
$data[$key] = $value;
320279
}
321280
} else {
322-
@trigger_error(sprintf('Duplicate key "%s" detected on line %d whilst parsing YAML. Silent handling of duplicate mapping keys in YAML is deprecated since version 3.2 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0.', $key, $realCurrentLineNbKey + 1), E_USER_DEPRECATED);
281+
throw new ParseException(sprintf('Duplicate key "%s" detected.', $key), $realCurrentLineNbKey + 1, $this->currentLine);
323282
}
324283
}
325284
} else {
@@ -329,7 +288,7 @@ private function doParse($value, $flags)
329288
if ($allowOverwrite || !isset($data[$key])) {
330289
$data[$key] = $value;
331290
} else {
332-
@trigger_error(sprintf('Duplicate key "%s" detected on line %d whilst parsing YAML. Silent handling of duplicate mapping keys in YAML is deprecated since version 3.2 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0.', $key, $this->getRealCurrentLineNb() + 1), E_USER_DEPRECATED);
291+
throw new ParseException(sprintf('Duplicate key "%s" detected.', $key), $this->getRealCurrentLineNb() + 1, $this->currentLine);
333292
}
334293
}
335294
if ($isRef) {
@@ -342,7 +301,7 @@ private function doParse($value, $flags)
342301
}
343302

344303
if (isset($this->currentLine[1]) && '?' === $this->currentLine[0] && ' ' === $this->currentLine[1]) {
345-
@trigger_error('Starting an unquoted string with a question mark followed by a space is deprecated since version 3.3 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0.', E_USER_DEPRECATED);
304+
throw new ParseException('Complex mappings are not supported.', $this->getRealCurrentLineNb() + 1, $this->currentLine);
346305
}
347306

348307
// 1-liner optionally followed by newline(s)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.