-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Yaml] Deprecate tags using colon #22913
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
Closed
Closed
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,12 @@ CHANGELOG | |
3.4.0 | ||
----- | ||
|
||
* Deprecated the tag`!php/object:` tag which will be replaced by the | ||
`!php/object` tag (without the colon) in 4.0. | ||
|
||
* Deprecated the tag`!php/const:` tag which will be replaced by the | ||
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. the "tag" in front of |
||
`!php/const` tag (without the colon) in 4.0. | ||
|
||
* Support for the `!str` tag is deprecated, use the `!!str` tag instead. | ||
|
||
* Deprecated using the non-specific tag `!` as its behavior will change in 4.0. | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -170,7 +170,7 @@ public static function dump($value, $flags = 0) | |
} | ||
|
||
if (Yaml::DUMP_OBJECT & $flags) { | ||
return '!php/object:'.serialize($value); | ||
return '!php/object '.self::dump(serialize($value)); | ||
} | ||
|
||
if (Yaml::DUMP_OBJECT_AS_MAP & $flags && ($value instanceof \stdClass || $value instanceof \ArrayObject)) { | ||
|
@@ -620,6 +620,8 @@ private static function evaluateScalar($scalar, $flags, $references = array()) | |
return (int) self::parseScalar(substr($scalar, 2), $flags); | ||
case 0 === strpos($scalar, '!php/object:'): | ||
if (self::$objectSupport) { | ||
@trigger_error('The !php/object: tag to indicate dumped PHP objects is deprecated since version 3.4 and will be removed in 4.0. Use the !php/object (without the colon) tag instead.', E_USER_DEPRECATED); | ||
|
||
return unserialize(substr($scalar, 12)); | ||
} | ||
|
||
|
@@ -630,7 +632,7 @@ private static function evaluateScalar($scalar, $flags, $references = array()) | |
return; | ||
case 0 === strpos($scalar, '!!php/object:'): | ||
if (self::$objectSupport) { | ||
@trigger_error('The !!php/object tag to indicate dumped PHP objects is deprecated since version 3.1 and will be removed in 4.0. Use the !php/object tag instead.', E_USER_DEPRECATED); | ||
@trigger_error('The !!php/object: tag to indicate dumped PHP objects is deprecated since version 3.1 and will be removed in 4.0. Use the !php/object (without the colon) tag instead.', E_USER_DEPRECATED); | ||
|
||
return unserialize(substr($scalar, 13)); | ||
} | ||
|
@@ -639,9 +641,21 @@ private static function evaluateScalar($scalar, $flags, $references = array()) | |
throw new ParseException('Object support when parsing a YAML file has been disabled.'); | ||
} | ||
|
||
return; | ||
case 0 === strpos($scalar, '!php/object'): | ||
if (self::$objectSupport) { | ||
return unserialize(self::parseScalar(substr($scalar, 12))); | ||
} | ||
|
||
if (self::$exceptionOnInvalidType) { | ||
throw new ParseException('Object support when parsing a YAML file has been disabled.'); | ||
} | ||
|
||
return; | ||
case 0 === strpos($scalar, '!php/const:'): | ||
if (self::$constantSupport) { | ||
@trigger_error('The !php/const: tag to indicate dumped PHP constants is deprecated since version 3.4 and will be removed in 4.0. Use the !php/const (without the colon) tag instead.', E_USER_DEPRECATED); | ||
|
||
if (defined($const = substr($scalar, 11))) { | ||
return constant($const); | ||
} | ||
|
@@ -652,6 +666,20 @@ private static function evaluateScalar($scalar, $flags, $references = array()) | |
throw new ParseException(sprintf('The string "%s" could not be parsed as a constant. Have you forgotten to pass the "Yaml::PARSE_CONSTANT" flag to the parser?', $scalar)); | ||
} | ||
|
||
return; | ||
|
||
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. no need for this blank line |
||
case 0 === strpos($scalar, '!php/const'): | ||
if (self::$constantSupport) { | ||
if (defined($const = self::parseScalar(substr($scalar, 11)))) { | ||
return constant($const); | ||
} | ||
|
||
throw new ParseException(sprintf('The constant "%s" is not defined.', $const)); | ||
} | ||
if (self::$exceptionOnInvalidType) { | ||
throw new ParseException(sprintf('The string "%s" could not be parsed as a constant. Have you forgotten to pass the "Yaml::PARSE_CONSTANT" flag to the parser?', $scalar)); | ||
} | ||
|
||
return; | ||
case 0 === strpos($scalar, '!!float '): | ||
return (float) substr($scalar, 8); | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
the "tag" in front of
!php/object:
should be removed