[Yaml] Clarify "incompatible key casting" deprecation message

This commit is contained in:
Richard van Laak 2017-06-02 10:44:49 +02:00 committed by Fabien Potencier
parent 60b89bb67f
commit 67895f4dd3
2 changed files with 4 additions and 3 deletions

View File

@ -237,7 +237,8 @@ class Parser
}
if (!(Yaml::PARSE_KEYS_AS_STRINGS & $flags) && !is_string($key)) {
@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);
$keyType = is_numeric($key) ? 'numeric key' : 'incompatible key type';
@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);
}
// Convert float keys to strings, to avoid being converted to integers by PHP

View File

@ -1081,7 +1081,7 @@ EOF;
/**
* @group legacy
* @expectedDeprecation 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.
* @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.
*/
public function testFloatKeys()
{
@ -1103,7 +1103,7 @@ EOF;
/**
* @group legacy
* @expectedDeprecation 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.
* @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.
*/
public function testBooleanKeys()
{