-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[Yaml] Add tags support #21194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Yaml] Add tags support #21194
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1495,7 +1495,7 @@ public function testParseMultiLineMappingValue() | |
|
||
public function testTaggedInlineMapping() | ||
{ | ||
$this->assertEquals(new TaggedValue(array('foo' => 'bar'), 'foo'), $this->parser->parse('!foo {foo: bar}', Yaml::PARSE_CUSTOM_TAGS)); | ||
$this->assertEquals(new TaggedValue('foo', array('foo' => 'bar')), $this->parser->parse('!foo {foo: bar}', Yaml::PARSE_CUSTOM_TAGS)); | ||
} | ||
|
||
/** | ||
|
@@ -1510,15 +1510,15 @@ public function taggedValuesProvider() | |
{ | ||
return array( | ||
'sequences' => array( | ||
array(new TaggedValue(array('yaml'), 'foo'), new TaggedValue(array('bar'), '!quz')), | ||
array(new TaggedValue('foo', array('yaml')), new TaggedValue('!quz', array('bar'))), | ||
<<<YAML | ||
- !foo | ||
- yaml | ||
- !!quz [bar] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tags starting with two exclamation marks are tags defined by the YAML spec. I do not think we should support them through a flag that indicates to parse custom tags (and if we want to parse built-in tags, we will have to validate their names IMO). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we throw an exception then? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree with @xabbuh - we need to keep BC of course There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done
7ABE
|
||
YAML | ||
), | ||
'mappings' => array( | ||
new TaggedValue(array('foo' => new TaggedValue(array('bar'), '!quz'), 'quz' => new TaggedValue(array('quz' => 'bar'), 'foo')), 'foo'), | ||
new TaggedValue('foo', array('foo' => new TaggedValue('!quz', array('bar')), 'quz' => new TaggedValue('foo', array('quz' => 'bar')))), | ||
<<<YAML | ||
!foo | ||
foo: !!quz [bar] | ||
|
@@ -1527,7 +1527,7 @@ public function taggedValuesProvider() | |
YAML | ||
), | ||
'inline' => array( | ||
array(new TaggedValue(array('foo', 'bar'), 'foo'), new TaggedValue(array('foo' => 'bar', 'quz' => new TaggedValue(array('one' => 'bar'), 'bar')), '!quz')), | ||
array(new TaggedValue('foo', array('foo', 'bar')), new TaggedValue('!quz', array('foo' => 'bar', 'quz' => new TaggedValue('bar', array('one' => 'bar'))))), | ||
<<<YAML | ||
- !foo [foo, bar] | ||
- !!quz {foo: bar, quz: !bar {one: bar}} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instanceof ArgumentInterface
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't know the tag corresponding to other instances so I think it's better this way here.