Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[DependencyInjection] improved message when alias service is not found #28449

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

Merged
merged 1 commit into from
Sep 23, 2018

Conversation

xabbuh
Copy link
Member

@xabbuh xabbuh commented Sep 11, 2018

Q A
Branch? 2.8
Bug fix? no
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #28413
License MIT
Doc PR

When using the YAML config format, it can be confusing that you need to
prefix the aliased service id with an @ character when passing it as
a string, but that you have to omit it when using the alias attribute:

foo: '@App\Foo'

foo:
    alias: 'App\Foo'

This commit will enhance the generated error message in cases where the
aliased service id is prefixed with the @ character in the alias
option like this:

foo:
    alias: '@App\Foo'

@nicolas-grekas
Copy link
Member

Should be for master, isn't it?

@stof
Copy link
Member

stof commented Sep 12, 2018

Indeed. We avoid doing such changes in patch releases generally.

@xabbuh
Copy link
Member Author

xabbuh commented Sep 13, 2018

rebased on master, I also updated the descriptors to provide more information there too (which is what was actually reported in #28413)

@xabbuh xabbuh changed the base branch from 2.8 to master September 13, 2018 13:37
@xabbuh xabbuh modified the milestones: 2.8, next Sep 13, 2018
@nicolas-grekas
Copy link
Member

Are the descriptor changes required? I mean: the pass will always catch this before descriptor ever hit this situation, isn't it? Would be great to reduce the complexity if possible.

@xabbuh
Copy link
Member Author

xabbuh commented Sep 17, 2018

Unfortunately, the pass is not executed when the command is run. All removal passes are disabled first.

@nicolas-grekas
Copy link
Member

But the commands run after the container is compiled, isn't it?

@xabbuh
Copy link
Member Author

xabbuh commented Sep 17, 2018

It uses a container that is compiled without the removal passes:

if (!$kernel->isDebug() || !(new ConfigCache($kernel->getContainer()->getParameter('debug.container.dump'), true))->isFresh()) {
$buildContainer = \Closure::bind(function () { return $this->buildContainer(); }, $kernel, \get_class($kernel));
$container = $buildContainer();
$container->getCompilerPassConfig()->setRemovingPasses(array());
$container->compile();

@chalasr
Copy link
Member

chalasr commented Sep 18, 2018

indeed, required for being able to list all available services including autowiring types

Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

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

OK, tested, I get it now. Here are some comments to fine tune the console output.

@xabbuh xabbuh force-pushed the issue-28413 branch 2 times, most recently from 3e31fb5 to 7844a47 Compare September 23, 2018 07:29
When using the YAML config format, it can be confusing that you need to
prefix the aliased service id with an `@` character when passing it as
a string, but that you have to omit it when using the `alias` attribute:

```yaml
foo: '@app\Foo'

foo:
    alias: 'App\Foo'
```

This commit will enhance the generated error message in cases where the
aliased service id is prefixed with the `@` character in the `alias`
option like this:

```yaml
foo:
    alias: '@app\Foo'
```
@fabpot
Copy link
Member

fabpot commented Sep 23, 2018

Thank you @xabbuh.

@fabpot fabpot merged commit 280ecbc into symfony:master Sep 23, 2018
fabpot added a commit that referenced this pull request Sep 23, 2018
…ice is not found (xabbuh)

This PR was merged into the 4.2-dev branch.

Discussion
----------

[DependencyInjection] improved message when alias service is not found

| Q             | A
| ------------- | ---
| Branch?       | 2.8
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #28413
| License       | MIT
| Doc PR        |

When using the YAML config format, it can be confusing that you need to
prefix the aliased service id with an `@` character when passing it as
a string, but that you have to omit it when using the `alias` attribute:

```yaml
foo: '@app\Foo'

foo:
    alias: 'App\Foo'
```

This commit will enhance the generated error message in cases where the
aliased service id is prefixed with the `@` character in the `alias`
option like this:

```yaml
foo:
    alias: '@app\Foo'
```

Commits
-------

280ecbc improved message when alias service is not found
@xabbuh xabbuh deleted the issue-28413 branch September 23, 2018 12:57
@nicolas-grekas nicolas-grekas modified the milestones: next, 4.2 Nov 1, 2018
This was referenced Nov 3, 2018
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.

6 participants