-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Yaml] dump customization option with dumper flags #17578
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
Conversation
xabbuh
commented
Jan 27, 2016
Q | A |
---|---|
Bug fix? | no |
New feature? | yes |
BC breaks? | no |
Deprecations? | yes |
Tests pass? | yes |
Fixed tickets | #17520 |
License | MIT |
Doc PR | symfony/symfony-docs#6226 |
@xabbuh thanks for working on this nice feature! I have a proposal regarding the new constants. You propose to define the constants in use Symfony\Component\Yaml\Yaml;
use Symfony\Component\Yaml\Dumper;
Yaml::dump(array('foo' => new A(), 'bar' => 1), 0, 0, false, Dumper::DUMP_OBJECT); I propose to define these constants in the main use Symfony\Component\Yaml\Yaml;
Yaml::dump(array('foo' => new A(), 'bar' => 1), 0, 0, false, Yaml::DUMP_OBJECT); What do you think about this? |
👍 |
@javiereguiluz Your suggestion sounds reasonable to me as the |
Good suggestion |
@@ -42,17 +44,23 @@ public function setIndentation($num) | |||
* @param int $inline The level where you switch to inline YAML | |||
* @param int $indent The level of indentation (used internally) | |||
* @param bool $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise | |||
* @param bool $objectSupport true if object support is enabled, false otherwise | |||
* @param int $flags A bit field of DUMP_* constants to customize the dumped YAML string |
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.
is bit
correct or is integer
better?
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.
Bit is right. Each future dumper option will get its own bit so that we can use PHP's bitwise operators to check if a particular dumper option was requested.
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.
👍
@javiereguiluz I moved the constant to the ping @symfony/deciders |
{ | ||
if (is_bool($flags)) { | ||
@trigger_error('Passing a boolean flag to toogle object support is deprecated since version 3.1 and will be removed in 4.0. Use the Dumper::DUMP_OBJECT flag instead.', E_USER_DEPRECATED); |
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.
Dumper::DUMP_OBJECT
-> Yaml::DUMP_OBJECT
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.
@DavidBadura Thanks for catching all these silly mistakes.
{ | ||
if (is_bool($flags)) { | ||
@trigger_error('Passing a boolean flag to toogle object support is deprecated since version 3.1 and will be removed in 4.0. Use the DUMP_OBJECT flag instead.', E_USER_DEPRECATED); |
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.
typo: toggle
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.
good catch, fixed everywhere
After: | ||
|
||
```php | ||
Yaml::dump(array('foo' => new A(), 'bar' => 1), 0, 0, false, Dumper::DUMP_OBJECT); |
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.
And here ;)
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.
oh, c'mon :D
👍 |
…bbuh) This PR was merged into the 3.1-dev branch. Discussion ---------- [Yaml] dump customization option with dumper flags | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | yes | Tests pass? | yes | Fixed tickets | #17520 | License | MIT | Doc PR | TODO Commits ------- 286103b [Yaml] dump customization option with dumper flags
…ger (xabbuh) This PR was merged into the 3.1-dev branch. Discussion ---------- [TwigBridge] deprecate the boolean object support trigger | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | yes | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | This reflects the changes done in the Yaml component in #17578. Commits ------- 27243c6 deprecate the boolean object support trigger
…r (xabbuh) This PR was merged into the 3.1-dev branch. Discussion ---------- [Yaml] introduce flags to customize the parser behavior | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | yes | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | TODO Since #17578 it is possible to customise dumped YAML strings with an optional bit field. This pull request does the same for the parser part of the Yaml component. Commits ------- 9cb8552 introduce flags to customize the parser behavior