You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
bug #23108 [Yaml] Remove line number in deprecation notices (nicolas-grekas)
This PR was merged into the 3.3 branch.
Discussion
----------
[Yaml] Remove line number in deprecation notices
| Q | A
| ------------- | ---
| Branch? | 3.3
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | -
| License | MIT
| Doc PR | -
While moving an app to 3.3, I noticed that my deprecation log is full of deprecation notices that differ only by some line number, but don't tell which file is concerned.
This makes the line number useless, and just prevents aggregation.

Commits
-------
f82b618 [Yaml] Remove line number in deprecation notices
@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);
498
498
}
499
499
}
@@ -519,7 +519,7 @@ private static function parseMapping($mapping, $flags, &$i = 0, $references = ar
519
519
// Parser cannot abort this mapping earlier, since lines
520
520
// are processed sequentially.
521
521
if (isset($output[$key])) {
522
-
@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
+
@trigger_error(sprintf('Duplicate key "%s" detected 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), E_USER_DEPRECATED);
523
523
$duplicate = true;
524
524
}
525
525
break;
@@ -530,7 +530,7 @@ private static function parseMapping($mapping, $flags, &$i = 0, $references = ar
530
530
// Parser cannot abort this mapping earlier, since lines
531
531
// are processed sequentially.
532
532
if (isset($output[$key])) {
533
-
@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
+
@trigger_error(sprintf('Duplicate key "%s" detected 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), E_USER_DEPRECATED);
534
534
$duplicate = true;
535
535
}
536
536
break;
@@ -540,7 +540,7 @@ private static function parseMapping($mapping, $flags, &$i = 0, $references = ar
540
540
// Parser cannot abort this mapping earlier, since lines
541
541
// are processed sequentially.
542
542
if (isset($output[$key])) {
543
-
@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
+
@trigger_error(sprintf('Duplicate key "%s" detected 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), E_USER_DEPRECATED);
@trigger_error(sprintf('Implicit casting of %s to string on line %d 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.', $keyType, $this->getRealCurrentLineNb()), E_USER_DEPRECATED);
239
+
if (!(Yaml::PARSE_KEYS_AS_STRINGS & $flags) && !is_string($key) && !is_int($key)) {
@trigger_error(sprintf('Implicit casting of %s to string 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.', $keyType), E_USER_DEPRECATED);
242
242
}
243
243
244
244
// Convert float keys to strings, to avoid being converted to integers by PHP
@@ -312,7 +312,7 @@ private function doParse($value, $flags)
312
312
$data[$key] = null;
313
313
}
314
314
} else {
315
-
@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);
315
+
@trigger_error(sprintf('Duplicate key "%s" detected 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), E_USER_DEPRECATED);
316
316
}
317
317
} else {
318
318
// remember the parsed line number here in case we need it to provide some contexts in error messages below
@@ -327,7 +327,7 @@ private function doParse($value, $flags)
327
327
$data[$key] = $value;
328
328
}
329
329
} else {
330
-
@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);
330
+
@trigger_error(sprintf('Duplicate key "%s" detected 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), E_USER_DEPRECATED);
331
331
}
332
332
}
333
333
} else {
@@ -337,7 +337,7 @@ private function doParse($value, $flags)
337
337
if ($allowOverwrite || !isset($data[$key])) {
338
338
$data[$key] = $value;
339
339
} else {
340
-
@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);
340
+
@trigger_error(sprintf('Duplicate key "%s" detected 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), E_USER_DEPRECATED);
@@ -1081,7 +1081,7 @@ public function testYamlDirective()
1081
1081
1082
1082
/**
1083
1083
* @group legacy
1084
-
* @expectedDeprecation Implicit casting of numeric key to string on line 1 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.
1084
+
* @expectedDeprecation Implicit casting of numeric key to string 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.
1085
1085
*/
1086
1086
publicfunctiontestFloatKeys()
1087
1087
{
@@ -1103,7 +1103,7 @@ public function testFloatKeys()
1103
1103
1104
1104
/**
1105
1105
* @group legacy
1106
-
* @expectedDeprecation Implicit casting of incompatible key type to string on line 1 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.
1106
+
* @expectedDeprecation Implicit casting of non-string key to string 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.
0 commit comments