8000 merged branch ezzatron/yaml-negative-integers (PR #6784) · unframework/symfony@0391ac7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0391ac7

Browse files
committed
merged branch ezzatron/yaml-negative-integers (PR symfony#6784)
This PR was merged into the 2.0 branch. Commits ------- fea20b7 [Yaml] fixed symfony#6770 Discussion ---------- [Yaml] fixed parsing of negative integers (2.0 branch) | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | symfony#6770 | License | MIT | Doc PR | n/a Note that an unrelated test fixture for large integers had to be changed to work on systems with 64-bit integer support because of the change from `assertEquals()` to `assertSame()`. Please see the diff for clarification.
2 parents 4d673d7 + fea20b7 commit 0391ac7

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/Symfony/Component/Yaml/Inline.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,11 @@ private static function evaluateScalar($scalar)
393393
$cast = intval($scalar);
394394

395395
return '0' == $scalar[0] ? octdec($scalar) : (((string) $raw == (string) $cast) ? $cast : $raw);
396+
case '-' === $scalar[0] && ctype_digit(substr($scalar, 1)):
397+
$raw = $scalar;
398+
$cast = intval($scalar);
399+
400+
return '0' == $scalar[1] ? octdec($scalar) : (((string) $raw == (string) $cast) ? $cast : $raw);
396401
case 'true' === strtolower($scalar):
397402
return true;
398403
case 'false' === strtolower($scalar):

tests/Symfony/Tests/Component/Yaml/InlineTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class InlineTest extends \PHPUnit_Framework_TestCase
1919
public function testParse()
2020
{
2121
foreach ($this->getTestsForParse() as $yaml => $value) {
22-
$this->assertEquals($value, Inline::parse($yaml), sprintf('::parse() converts an inline YAML to a PHP structure (%s)', $yaml));
22+
$this->assertSame($value, Inline::parse($yaml), sprintf('::parse() converts an inline YAML to a PHP structure (%s)', $yaml));
2323
}
2424
}
2525

@@ -73,6 +73,7 @@ protected function getTestsForParse()
7373
'false' => false,
7474
'true' => true,
7575
'12' => 12,
76+
'-12' => -12,
7677
'"quoted string"' => 'quoted string',
7778
"'quoted string'" => 'quoted string',
7879
'12.30e+02' => 12.30e+02,
@@ -82,7 +83,7 @@ protected function getTestsForParse()
8283
'-.Inf' => log(0),
8384
"'686e444'" => '686e444',
8485
'686e444' => 646e444,
85-
'123456789123456789' => '123456789123456789',
86+
'123456789123456789123456789123456789' => '123456789123456789123456789123456789',
8687
'"foo\r\nbar"' => "foo\r\nbar",
8788
"'foo#bar'" => 'foo#bar',
8889
"'foo # bar'" => 'foo # bar',

0 commit comments

Comments
 (0)
0