Skip to content

Commit

Permalink
[Yaml] fixed #6770
Browse files Browse the repository at this point in the history
  • Loading branch information
ezzatron committed Jan 17, 2013
1 parent 4c437f6 commit fea20b7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/Symfony/Component/Yaml/Inline.php
Expand Up @@ -393,6 +393,11 @@ private static function evaluateScalar($scalar)
$cast = intval($scalar);

return '0' == $scalar[0] ? octdec($scalar) : (((string) $raw == (string) $cast) ? $cast : $raw);
case '-' === $scalar[0] && ctype_digit(substr($scalar, 1)):
$raw = $scalar;
$cast = intval($scalar);

return '0' == $scalar[1] ? octdec($scalar) : (((string) $raw == (string) $cast) ? $cast : $raw);
case 'true' === strtolower($scalar):
return true;
case 'false' === strtolower($scalar):
Expand Down
5 changes: 3 additions & 2 deletions tests/Symfony/Tests/Component/Yaml/InlineTest.php
Expand Up @@ -19,7 +19,7 @@ class InlineTest extends \PHPUnit_Framework_TestCase
public function testParse()
{
foreach ($this->getTestsForParse() as $yaml => $value) {
$this->assertEquals($value, Inline::parse($yaml), sprintf('::parse() converts an inline YAML to a PHP structure (%s)', $yaml));
$this->assertSame($value, Inline::parse($yaml), sprintf('::parse() converts an inline YAML to a PHP structure (%s)', $yaml));
}
}

Expand Down Expand Up @@ -73,6 +73,7 @@ protected function getTestsForParse()
'false' => false,
'true' => true,
'12' => 12,
'-12' => -12,
'"quoted string"' => 'quoted string',
"'quoted string'" => 'quoted string',
'12.30e+02' => 12.30e+02,
Expand All @@ -82,7 +83,7 @@ protected function getTestsForParse()
'-.Inf' => log(0),
"'686e444'" => '686e444',
'686e444' => 646e444,
'123456789123456789' => '123456789123456789',
'123456789123456789123456789123456789' => '123456789123456789123456789123456789',
'"foo\r\nbar"' => "foo\r\nbar",
"'foo#bar'" => 'foo#bar',
"'foo # bar'" => 'foo # bar',
Expand Down

0 comments on commit fea20b7

Please sign in to comment.