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
minor #21342 [DependencyInjection] YAML: reduce the complexity of the _defaults parser (dunglas)
This PR was merged into the 3.3-dev branch.
Discussion
----------
[DependencyInjection] YAML: reduce the complexity of the _defaults parser
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | no
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | n/a
| License | MIT
| Doc PR | n/a
Commits
-------
130fa1f [DependencyInjection] YAML: reduce the complexity of the _defaults parser
if (!is_array($defaults = $content['services']['_defaults'])) {
181
+
thrownewInvalidArgumentException(sprintf('Service defaults must be an array, "%s" given in "%s".', gettype($defaults), $file));
182
+
}
183
+
if (isset($defaults['alias']) || isset($defaults['class']) || isset($defaults['factory'])) {
184
+
@trigger_error('Giving a service the "_defaults" name is deprecated since Symfony 3.3 and will be forbidden in 4.0. Rename your service.', E_USER_DEPRECATED);
thrownewInvalidArgumentException(sprintf('The configuration key "%s" cannot be used to define a default value in "%s". Allowed keys are "%s".', $key, $file, implode('", "', $defaultKeys)));
163
195
}
164
-
if (isset($defaults['alias']) || isset($defaults['class']) || isset($defaults['factory'])) {
165
-
@trigger_error('Giving a service the "_defaults" name is deprecated since Symfony 3.3 and will be forbidden in 4.0. Rename your service.', E_USER_DEPRECATED);
thrownewInvalidArgumentException(sprintf('Parameter "tags" in "_defaults" must be an array in %s. Check your YAML syntax.', $file));
202
+
}
170
203
171
-
foreach ($defaultsas$key => $default) {
172
-
if (!in_array($key, $defaultKeys)) {
173
-
thrownewInvalidArgumentException(sprintf('The configuration key "%s" cannot be used to define a default value in "%s". Allowed keys are "%s".', $key, $file, implode('", "', $defaultKeys)));
174
-
}
175
-
}
176
-
if (isset($defaults['tags'])) {
177
-
if (!is_array($tags = $defaults['tags'])) {
178
-
thrownewInvalidArgumentException(sprintf('Parameter "tags" in "_defaults" must be an array in %s. Check your YAML syntax.', $file));
179
-
}
204
+
foreach ($tagsas$tag) {
205
+
if (!is_array($tag)) {
206
+
$tag = array('name' => $tag);
207
+
}
180
208
181
-
foreach ($tagsas$tag) {
182
-
if (!is_array($tag)) {
183
-
$tag = array('name' => $tag);
184
-
}
185
-
186
-
if (!isset($tag['name'])) {
187
-
thrownewInvalidArgumentException(sprintf('A "tags" entry in "_defaults" is missing a "name" key in %s.', $file));
188
-
}
189
-
$name = $tag['name'];
190
-
unset($tag['name']);
191
-
192
-
if (!is_string($name) || '' === $name) {
193
-
thrownewInvalidArgumentException(sprintf('The tag name in "_defaults" must be a non-empty string in %s.', $file));
194
-
}
195
-
196
-
foreach ($tagas$attribute => $value) {
197
-
if (!is_scalar($value) && null !== $value) {
198
-
thrownewInvalidArgumentException(sprintf('Tag "%s", attribute "%s" in "_defaults" must be of a scalar-type in %s. Check your YAML syntax.', $name, $attribute, $file));
199
-
}
200
-
}
201
-
}
209
+
if (!isset($tag['name'])) {
210
+
thrownewInvalidArgumentException(sprintf('A "tags" entry in "_defaults" is missing a "name" key in %s.', $file));
211
+
}
212
+
$name = $tag['name'];
213
+
unset($tag['name']);
214
+
215
+
if (!is_string($name) || '' === $name) {
216
+
thrownewInvalidArgumentException(sprintf('The tag name in "_defaults" must be a non-empty string in %s.', $file));
217
+
}
218
+
219
+
foreach ($tagas$attribute => $value) {
220
+
if (!is_scalar($value) && null !== $value) {
221
+
thrownewInvalidArgumentException(sprintf('Tag "%s", attribute "%s" in "_defaults" must be of a scalar-type in %s. Check your YAML syntax.', $name, $attribute, $file));
0 commit comments