Skip to content

Commit f2570f2

Browse files
committed
Merge branch '6.1' into 6.2
* 6.1: parse unquoted digits in tag values as integers do not wire the MercureTransportFactory if the MercureBundle is not enabled skip tests if the signal to be sent is not available skip a test if the signal to be sent is not available
2 parents d3cf343 + 20e9985 commit f2570f2

File tree

5 files changed

+24
-19
lines changed

5 files changed

+24
-19
lines changed

Inline.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public static function parse(string $value = null, int $flags = 0, array &$refer
7777
++$i;
7878
break;
7979
default:
80-
$result = self::parseScalar($value, $flags, null, $i, null === $tag, $references);
80+
$result = self::parseScalar($value, $flags, null, $i, true, $references);
8181
}
8282

8383
// some comments are allowed at the end
@@ -677,7 +677,6 @@ private static function evaluateScalar(string $scalar, int $flags, array &$refer
677677
}
678678

679679
return octdec($value);
680-
// Optimize for returning strings.
681680
case \in_array($scalar[0], ['+', '-', '.'], true) || is_numeric($scalar[0]):
682681
if (Parser::preg_match('{^[+-]?[0-9][0-9_]*$}', $scalar)) {
683682
$scalar = str_replace('_', '', $scalar);

Tests/DumperTest.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -473,8 +473,6 @@ public function testDumpingTaggedValueSequenceWithInlinedTagValues()
473473
474474
YAML;
475475
$this->assertSame($expected, $yaml);
476-
// @todo Fix the parser, preserve numbers.
477-
$data[2] = new TaggedValue('number', '5');
478476
$this->assertSameData($data, $this->parser->parse($expected, Yaml::PARSE_CUSTOM_TAGS));
479477
}
480478

@@ -503,8 +501,6 @@ public function testDumpingTaggedValueMapRespectsInlineLevel()
503501
504502
YAML;
505503
$this->assertSame($expected, $yaml);
506-
// @todo Fix the parser, preserve numbers.
507-
$data['count'] = new TaggedValue('number', '5');
508504
$this->assertSameData($data, $this->parser->parse($expected, Yaml::PARSE_CUSTOM_TAGS));
509505
}
510506

@@ -558,9 +554,6 @@ public function testDumpingNotInlinedNullTaggedValue()
558554
YAML;
559555

560556
$this->assertSame($expected, $this->dumper->dump($data, 2));
561-
562-
// @todo Fix the parser, don't stringify null.
563-
$data['foo'] = new TaggedValue('bar', 'null');
564557
$this->assertSameData($data, $this->parser->parse($expected, Yaml::PARSE_CUSTOM_TAGS | Yaml::PARSE_CONSTANT));
565558
}
566559

Tests/Fixtures/YtsSpecificationExamples.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -913,7 +913,7 @@ yaml: |
913913
no int: ! 12
914914
string: !!str 12
915915
php: |
916-
[ 'integer' => 12, 'no int' => '12', 'string' => '12' ]
916+
[ 'integer' => 12, 'no int' => 12, 'string' => '12' ]
917917
---
918918
test: Private types
919919
todo: true

Tests/InlineTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,24 @@ public function testTagWithEmptyValueInMapping()
784784
$this->assertSame('', $value['foo']->getValue());
785785
}
786786

787+
public function testTagWithQuotedInteger()
788+
{
789+
$value = Inline::parse('!number "5"', Yaml::PARSE_CUSTOM_TAGS);
790+
791+
$this->assertInstanceOf(TaggedValue::class, $value);
792+
$this->assertSame('number', $value->getTag());
793+
$this->assertSame('5', $value->getValue());
794+
}
795+
796+
public function testTagWithUnquotedInteger()
797+
{
798+
$value = Inline::parse('!number 5', Yaml::PARSE_CUSTOM_TAGS);
799+
800+
$this->assertInstanceOf(TaggedValue::class, $value);
801+
$this->assertSame('number', $value->getTag());
802+
$this->assertSame(5, $value->getValue());
803+
}
804+
787805
public function testUnfinishedInlineMap()
788806
{
789807
$this->expectException(ParseException::class);

Tests/ParserTest.php

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,16 @@ public function testTaggedValueTopLevelNumber()
5656
{
5757
$yml = '!number 5';
5858
$data = $this->parser->parse($yml, Yaml::PARSE_CUSTOM_TAGS);
59-
// @todo Preserve the number, don't turn into string.
60-
$expected = new TaggedValue('number', '5');
59+
$expected = new TaggedValue('number', 5);
6160
$this->assertSameData($expected, $data);
6261
}
6362

6463
public function testTaggedValueTopLevelNull()
6564
{
6665
$yml = '!tag null';
6766
$data = $this->parser->parse($yml, Yaml::PARSE_CUSTOM_TAGS);
68-
// @todo Preserve literal null, don't turn into string.
69-
$expected = new TaggedValue('tag', 'null');
70-
$this->assertSameData($expected, $data);
67+
68+
$this->assertSameData(new TaggedValue('tag', null), $data);
7169
}
7270

7371
public function testTaggedValueTopLevelString()
@@ -1557,9 +1555,6 @@ public function testParseDateAsMappingValue()
15571555
}
15581556

15591557
/**
1560-
* @param $lineNumber
1561-
* @param $yaml
1562-
*
15631558
* @dataProvider parserThrowsExceptionWithCorrectLineNumberProvider
15641559
*/
15651560
public function testParserThrowsExceptionWithCorrectLineNumber($lineNumber, $yaml)
@@ -2313,7 +2308,7 @@ public function taggedValuesProvider()
23132308

23142309
public function testNonSpecificTagSupport()
23152310
{
2316-
$this->assertSame('12', $this->parser->parse('! 12'));
2311+
$this->assertSame(12, $this->parser->parse('! 12'));
23172312
}
23182313

23192314
public function testCustomTagsDisabled()

0 commit comments

Comments
 (0)