Skip to content

[DependencyInjection] Optimize out "current()" when it's used as service factory #49523

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
Feb 24, 2023

Conversation

nicolas-grekas
Copy link
Member

Q A
Branch? 6.3
Bug fix? no
New feature? no
Deprecations? no
Tickets -
License MIT
Doc PR -

Sometimes, we need to use the "identity function" as a service factory.
One example is #49513, where we use that to create a "tagged alias".

In PHP, the identity function is current([$foo]).
Let's optimize out such calls.

@carsonbot carsonbot added this to the 6.3 milestone Feb 24, 2023
@nicolas-grekas nicolas-grekas changed the title [DependencyInjection] Optimize out "current()" when itss used as service factory [DependencyInjection] Optimize out "current()" when it's used as service factory Feb 24, 2023
$container->compile();
$dumper = new PhpDumper($container);
$dump = $dumper->dump(['class' => 'Symfony_DI_PhpDumper_Service_CurrentFactoryInlining']);
file_put_contents(self::$fixturesPath.'/php/services_current_factory_inlining.php', $dump);
Copy link
Member

Choose a reason for hiding this comment

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

@nicolas-grekas I think this was left here by mistake.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oops, fixed in 29054b1

@nicolas-grekas nicolas-grekas deleted the di-current branch February 24, 2023 23:38
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.

3 participants