-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DependencyInjection] Deprecate unsupported attributes/elements for alias #17323
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
The yaml test is not in the scope of this PR... Anyway, I'm not sure we should cry if these attributees are set, they will be ignored anyway.. |
private function validateAlias(\DOMElement $alias, $file) | ||
{ | ||
foreach (array('class', 'shared', 'synthetic', 'lazy', 'abstract', 'parent', 'decorates', 'decoration-inner-name', 'decoration-priority', 'autowire') as $key) { | ||
if ($alias->getAttribute($key)) { |
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.
Any reason getAttribute()
is used here instead of hasAttribute()
?
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.
No I didn't know this function
{ | ||
foreach ($alias->attributes as $name => $node) { | ||
if (!in_array($name, array('alias', 'id', 'public'))) { | ||
@trigger_error(sprintf('Using the attribute "%s" is deprecated for alias definition "%s" in "%s". Allowed attributes are "alias", "id" and "public". The XmlFileLoader object will raise an exception instead in Symfony 4.0 when detecting an unsupported attribute.', $key, $alias->getAttribute('id'), $file), 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.
I'd improve the second sentence slightly in all these deprecation messages and say "The XmlFileLoader object will raise an exception in Symfony 4.0, instead of silently ignoring unsupported attributes.".
Currently the message says "will raise an exception instead" but it doesn't say instead of what.
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.
👍 updated.
👍 |
@@ -491,6 +493,26 @@ public function validateSchema(\DOMDocument $dom) | ||
} | ||
|
||
/** | ||
* Validates an alias. | ||
* | ||
* @param \DOMElement |
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.
missing documentation for the $file
parameter
I would remove "object" from "The YamlFileLoader object will [...]" (same for the XmlFileLoader messages). Status: Needs work |
$loader->load('legacy_invalid_alias_definition.yml'); | ||
|
||
$this->assertTrue($container->has('foo')); | ||
|
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.
There seem to be trailing witespaces.
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.
Oops you're right
👍 Status: Reviewed |
ping |
Thank you @Ener-Getick. |
…/elements for alias (Ener-Getick) This PR was squashed before being merged into the 3.1-dev branch (closes #17323). Discussion ---------- [DependencyInjection] Deprecate unsupported attributes/elements for alias | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | yes | Tests pass? | yes | Fixed tickets | #17256 | License | MIT Following #17133, this PR deprecates using unsupported keywords on alias definition. For example the following examples will trigger deprecations: ```xml <?xml version="1.0" encoding="utf-8"?> <container> <services> <service id="bar" alias="foo" class="Foo"> <tag name="foo.bar" /> </service> </services> </container> ``` ```yml services: bar: alias: foo parent: quz ``` Commits ------- 49eb65c [DependencyInjection] Deprecate unsupported attributes/elements for alias
Following #17133, this PR deprecates using unsupported keywords on alias definition.
For example the following examples will trigger deprecations: