8000 [DependencyInjection] Fixed resolving of service configurators containing Definition objects by webmozart · Pull Request #14835 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[DependencyInjection] Fixed resolving of service configurators containing Definition objects #14835

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
Jun 11, 2015

Conversation

webmozart
Copy link
Contributor
Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #14834
License MIT
Doc PR -

if (is_array($callable)) {
$callable[0] = $callable[0] instanceof Reference ? $this->get((string) $callable[0]) : $parameterBag->resolveValue($callable[0]);
}
$callable = $this->resolveServices($parameterBag->resolveValue($callable));
Copy link
Member

Choose a reason for hiding this comment

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

this now allows expressions too, which looks wrong to me

Copy link
Contributor Author

Choose a reason for hiding this comment

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

why not be consistent with the rest?

Copy link
Member

Choose a reason for hiding this comment

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

Expressions are not supported in configurators in other places. They are only supported in arguments. So you don't introduce consistency but inconsistency (and using an expression for the service instance of the callable does not make sense either btw)

Copy link
Member

Choose a reason for hiding this comment

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

I agree with @stof.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alright. What solution do you propose then? Duplicate resolveServices() and remove expression support from the duplicate? Any naming suggestions?

Copy link
Member

Choose a reason for hiding this comment

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

well, we don't need to support the case of arrays either for configurators first element. So this is just a matter of adding the support of Definition object in the current code (which already supports references)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, but that means we still have duplicated and potentially buggy code. If somebody adds functionality to resolveServices(), they need to think about changing this code too (like happened before). IMO this should be fixed.

@webmozart
Copy link
Contributor Author

I updated the PR to match @stof's comments. I don't like this solution however, because the duplicated code in createService() and resolvedServices() bears potential for new bugs.

@fabpot
Copy link
Member
fabpot commented Jun 11, 2015

👍

@fabpot
Copy link
Member
fabpot commented Jun 11, 2015

Thank you @webmozart.

@fabpot fabpot merged commit 6ebcddd into symfony:2.7 Jun 11, 2015
fabpot added a commit that referenced this pull request Jun 11, 2015
…tors containing Definition objects (webmozart)

This PR was merged into the 2.7 branch.

Discussion
----------

[DependencyInjection] Fixed resolving of service configurators containing Definition objects

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

Commits
-------

6ebcddd [DependencyInjection] Fixed resolving of service configurators containing Definition objects
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.

4 participants
0