8000 [DependencyInjection] Add argument type `closure` to help passing closures to services by nicolas-grekas · Pull Request #45878 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[DependencyInjection] Add argument type closure to help passing closures to services #45878

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
Mar 30, 2022

Conversation

nicolas-grekas
Copy link
Member
Q A
Branch? 6.1
Bug fix? no
New feature? yes
Deprecations? no
Tickets -
License MIT
Doc PR -

Inspired by #45873

This makes it easier to inject invokable services as closures.

Before:

services:
  # [...]
    arguments:
      - !service
          class: Closure
          factory: [Closure, fromCallable]
          arguments: ['@my.invokable']

After:

services:
  # [...]
    arguments:
      - !closure '@my.invokable'

As a bonus, PhpDumper now optimizes Closure::fromCallable into first-class callable syntax.

@fabpot
Copy link
Member

fabpot commented Mar 30, 2022

Thank you @nicolas-grekas.

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
0