You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feature #17730 [Yaml] introduce flags to customize the parser behavior (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
@trigger_error('Passing a boolean flag to toggle exception handling is deprecated since version 3.1 and will be removed in 4.0. Use the Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE flag instead.', E_USER_DEPRECATED);
45
+
46
+
if ($flags) {
47
+
$flags = Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE;
48
+
} else {
49
+
$flags = 0;
50
+
}
51
+
}
52
+
53
+
if (func_num_args() >= 3 && !is_array($references)) {
54
+
@trigger_error('Passing a boolean flag to toggle object support is deprecated since version 3.1 and will be removed in 4.0. Use the Yaml::PARSE_OBJECT flag instead.', E_USER_DEPRECATED);
55
+
56
+
if ($references) {
57
+
$flags |= Yaml::PARSE_OBJECT;
58
+
}
59
+
60
+
if (func_num_args() >= 4) {
61
+
@trigger_error('Passing a boolean flag to toggle object for map support is deprecated since version 3.1 and will be removed in 4.0. Use the Yaml::PARSE_OBJECT_FOR_MAP flag instead.', E_USER_DEPRECATED);
@trigger_error('Passing a boolean flag to toggle exception handling is deprecated since version 3.1 and will be removed in 4.0. Use the Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE flag instead.', E_USER_DEPRECATED);
55
+
56
+
if ($flags) {
57
+
$flags = Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE;
58
+
} else {
59
+
$flags = 0;
60
+
}
61
+
}
62
+
63
+
if (func_num_args() >= 3) {
64
+
@trigger_error('Passing a boolean flag to toggle object support is deprecated since version 3.1 and will be removed in 4.0. Use the Yaml::PARSE_OBJECT flag instead.', E_USER_DEPRECATED);
65
+
66
+
if (func_get_arg(2)) {
67
+
$flags |= Yaml::PARSE_OBJECT;
68
+
}
69
+
}
70
+
71
+
if (func_num_args() >= 4) {
72
+
@trigger_error('Passing a boolean flag to toggle object for map support is deprecated since version 3.1 and will be removed in 4.0. Use the Yaml::PARSE_OBJECT_FOR_MAP flag instead.', E_USER_DEPRECATED);
73
+
74
+
if (func_get_arg(3)) {
75
+
$flags |= Yaml::PARSE_OBJECT_FOR_MAP;
76
+
}
77
+
}
78
+
55
79
if (!preg_match('//u', $value)) {
56
80
thrownewParseException('The YAML value does not appear to be valid UTF-8.');
57
81
}
@@ -95,7 +119,7 @@ public function parse($value, $exceptionOnInvalidType = false, $objectSupport =
0 commit comments