Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[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

Closed
wants to merge 2 commits into from

Conversation

GuilhemN
Copy link
Contributor

@GuilhemN GuilhemN commented Jan 9, 2016

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 version="1.0" encoding="utf-8"?>
<container>
  <services>
    <service id="bar" alias="foo" class="Foo">
        <tag name="foo.bar" />
    </service>
  </services>
</container>
services:
    bar:
        alias: foo
        parent: quz

@Taluu
Copy link
Contributor

Taluu commented Jan 10, 2016

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..

@GuilhemN
Copy link
Contributor Author

@Taluu the goal is the same as described in #17133: avoid mistakes and simplify debugging.

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)) {
Copy link
Contributor

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()?

Copy link
Contributor Author

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);
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 updated.

@nicolas-grekas
Copy link
Member

👍
Status: reviewed

@@ -491,6 +493,26 @@ public function validateSchema(\DOMDocument $dom)
}

/**
* Validates an alias.
*
* @param \DOMElement
Copy link
Member

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

@xabbuh
Copy link
Member

xabbuh commented Jan 14, 2016

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'));

Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops you're right

@xabbuh
Copy link
Member

xabbuh commented Jan 14, 2016

👍

Status: Reviewed

@GuilhemN
Copy link
Contributor Author

ping

@fabpot
Copy link
Member

fabpot commented Jan 16, 2016

Thank you @Ener-Getick.

@fabpot fabpot closed this Jan 16, 2016
fabpot added a commit that referenced this pull request Jan 16, 2016
…/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
@GuilhemN GuilhemN deleted the ALIAS branch January 16, 2016 14:25
@fabpot fabpot mentioned this pull request May 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.