Skip to content

Commit eb85bd1

Browse files
committed
Merge branch '5.4' into 6.0
* 5.4: 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 e65020d + ebd37c7 commit eb85bd1

File tree

5 files changed

+25
-19
lines changed

5 files changed

+25
-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
@@ -631,7 +631,6 @@ private static function evaluateScalar(string $scalar, int $flags, array &$refer
631631
}
632632

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

Tests/DumperTest.php

Lines changed: 1 addition & 8 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

@@ -677,7 +670,7 @@ public function testDumpMultiLineStringAsScalarBlock()
677670
nested_inlined_multi_line_string: { inlined_multi_line: "foo\nbar\r\nempty line:\n\nbaz" }
678671

679672
YAML
680-
);
673+
);
681674
$this->assertSame($expected, $yml);
682675
$this->assertSame($data, $this->parser->parse($yml));
683676
}

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
@@ -740,6 +740,24 @@ public function testTagWithEmptyValueInMapping()
740740
$this->assertSame('', $value['foo']->getValue());
741741
}
742742

743+
public function testTagWithQuotedInteger()
744+
{
745+
$value = Inline::parse('!number "5"', Yaml::PARSE_CUSTOM_TAGS);
746+
747+
$this->assertInstanceOf(TaggedValue::class, $value);
748+
$this->assertSame('number', $value->getTag());
749+
$this->assertSame('5', $value->getValue());
750+
}
751+
752+
public function testTagWithUnquotedInteger()
753+
{
754+
$value = Inline::parse('!number 5', Yaml::PARSE_CUSTOM_TAGS);
755+
756+
$this->assertInstanceOf(TaggedValue::class, $value);
757+
$this->assertSame('number', $value->getTag());
758+
$this->assertSame(5, $value->getValue());
759+
}
760+
743761
public function testUnfinishedInlineMap()
744762
{
745763
$this->expectException(ParseException::class);

Tests/ParserTest.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,18 +54,16 @@ public function testTaggedValueTopLevelNumber()
5454
{
5555
$yml = '!number 5';
5656
$data = $this->parser->parse($yml, Yaml::PARSE_CUSTOM_TAGS);
57-
// @todo Preserve the number, don't turn into string.
58-
$expected = new TaggedValue('number', '5');
57+
$expected = new TaggedValue('number', 5);
5958
$this->assertSameData($expected, $data);
6059
}
6160

6261
public function testTaggedValueTopLevelNull()
6362
{
6463
$yml = '!tag null';
6564
$data = $this->parser->parse($yml, Yaml::PARSE_CUSTOM_TAGS);
66-
// @todo Preserve literal null, don't turn into string.
67-
$expected = new TaggedValue('tag', 'null');
68-
$this->assertSameData($expected, $data);
65+
66+
$this->assertSameData(new TaggedValue('tag', null), $data);
6967
}
7068

7169
public function testTaggedValueTopLevelString()
@@ -1555,8 +1553,6 @@ public function testParseDateAsMappingValue()
15551553
}
15561554

15571555
/**
1558-
* @param $lineNumber
1559-
* @param $yaml
15601556
* @dataProvider parserThrowsExceptionWithCorrectLineNumberProvider
15611557
*/
15621558
public function testParserThrowsExceptionWithCorrectLineNumber($lineNumber, $yaml)
@@ -2310,7 +2306,7 @@ public function taggedValuesProvider()
23102306

23112307
public function testNonSpecificTagSupport()
23122308
{
2313-
$this->assertSame('12', $this->parser->parse('! 12'));
2309+
$this->assertSame(12, $this->parser->parse('! 12'));
23142310
}
23152311

23162312
public function testCustomTagsDisabled()

0 commit comments

Comments
 (0)