Skip to content

[DI] Do not set values of lazy arguments after inlining them #21312

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
Jan 18, 2017

Conversation

chalasr
Copy link
Member

@chalasr chalasr commented Jan 16, 2017

Q A
Branch? master
Bug fix? not yet
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #21299
License MIT
Doc PR n/a

@nicolas-grekas
Copy link
Member

Missing test ;)

@chalasr chalasr force-pushed the di/inlined-def-fix branch 3 times, most recently from 5523b21 to bb0ad49 Compare January 16, 2017 19:59
@chalasr
Copy link
Member Author

chalasr commented Jan 16, 2017

Test added!

@nicolas-grekas
Copy link
Member

👍

@@ -68,8 +67,6 @@ private function inlineArguments(ContainerBuilder $container, array $arguments,
}
if (is_array($argument)) {
$arguments[$k] = $this->inlineArguments($container, $argument);
} elseif ($argument instanceof ArgumentInterface) {
$argument->setValues($this->inlineArguments($container, $argument->getValues()));
Copy link
Member

Choose a reason for hiding this comment

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

by removing this, we miss the opportunity to inline inside lazy arguments.
only the call to setValue should be removed in fact

Copy link
Member Author

Choose a reason for hiding this comment

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

I didn't dare to ask you about that. Updated

@chalasr chalasr force-pushed the di/inlined-def-fix branch from bb0ad49 to 98c975c Compare January 17, 2017 13:58
@chalasr chalasr changed the title [DependencyInjection] Do not inline values of lazy arguments [DependencyInjection] Do not set values of lazy arguments after inlining them Jan 17, 2017
@chalasr chalasr changed the title [DependencyInjection] Do not set values of lazy arguments after inlining them [DI] Do not set values of lazy arguments after inlining them Jan 17, 2017

$this->process($container);

$values = $container->getDefinition('closure-proxy')->getArguments()[0]->getValues();
Copy link
Member

Choose a reason for hiding this comment

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

just use getArgument(0) here

Copy link
Member Author

Choose a reason for hiding this comment

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

it was a quick copy-paste, fixed

$this->assertInstanceOf(Reference::class, $values[0]);
$this->assertSame('inline', (string) $values[0]);

$values = $container->getDefinition('iterator')->getArguments()[0]->getValues();
Copy link
Member

Choose a reason for hiding this comment

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

same here

@chalasr chalasr force-pushed the di/inlined-def-fix branch from 98c975c to 04da7c3 Compare January 17, 2017 21:13
@@ -69,7 +69,7 @@ private function inlineArguments(ContainerBuilder $container, array $arguments,
if (is_array($argument)) {
$arguments[$k] = $this->inlineArguments($container, $argument);
} elseif ($argument instanceof ArgumentInterface) {
$argument->setValues($this->inlineArguments($container, $argument->getValues()));
$this->inlineArguments($container, $argument->getValues());
Copy link
Member

Choose a reason for hiding this comment

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

Is there any case where this could break? For example, if someone uses their own implementation of ArgumentInterface for whatever reason?

Copy link
Member

Choose a reason for hiding this comment

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

To answer my own question: the ArgumentInterface wasn't part of any release yet.

@xabbuh
Copy link
Member

xabbuh commented Jan 17, 2017

👍

Status: Reviewed

@fabpot
Copy link
Member

fabpot commented Jan 18, 2017

Thank you @chalasr.

@fabpot fabpot merged commit 04da7c3 into symfony:master Jan 18, 2017
fabpot added a commit that referenced this pull request Jan 18, 2017
…em (chalasr)

This PR was merged into the 3.3-dev branch.

Discussion
----------

[DI] Do not set values of lazy arguments after inlining them

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | not yet
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #21299
| License       | MIT
| Doc PR        | n/a

Commits
-------

04da7c3 [DI] Do not inline values of lazy arguments
@chalasr chalasr deleted the di/inlined-def-fix branch January 18, 2017 07:47
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.

5 participants