Skip to content
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

[RFC] [DependencyInjection] Automatically detect definitions class based on their factory #19161

Closed
GuilhemN opened this issue Jun 23, 2016 · 4 comments
Labels
DependencyInjection Feature RFC RFC = Request For Comments (proposals about features that you want to be discussed)

Comments

@GuilhemN
Copy link
Contributor

GuilhemN commented Jun 23, 2016

Thanks to the features of php 7.0 we can now guess the class of a service created with a factory:

function myFactory(): MyServiceClass
{
}

So I propose to create a new pass to automatically update the services definition when possible. This is particularly useful for autowiring (this way you don't have to copy-paste the class name of the service, especially when this is from a third party library).

What do you think ?

An implementation could be this.

@javiereguiluz javiereguiluz added DependencyInjection Feature RFC RFC = Request For Comments (proposals about features that you want to be discussed) labels Jun 26, 2016
@javiereguiluz javiereguiluz changed the title [Proposal][DependencyInjection] Automatically detect definitions class based on their factory [RFC] [DependencyInjection] Automatically detect definitions class based on their factory Jun 26, 2016
@TomasVotruba
Copy link
Contributor

This is must have. Already know it from other DI frameworks.

@GuilhemN
Copy link
Contributor Author

I opened #19191, please review it in case you see something to change :)

fabpot added a commit that referenced this issue Sep 19, 2016
…ions class when possible (Ener-Getick)

This PR was merged into the 3.2-dev branch.

Discussion
----------

[DependencyInjection] Automatically detect the definitions class when possible

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

> Thanks to the features of php 7.0 we can now guess the class of a service created with a factory:
> ```php
> function myFactory(): MyServiceClass
> {
> }
> ```
>
> So I propose to create a new pass to automatically update the services definition when possible. This is particularly useful for autowiring (this way you don't have to copy-paste the class name of the service, especially when this is from a third party library).
>
> What do you think ?

Commits
-------

63afe3c [DependencyInjection] Automatically detect the definitions class when possible
@fabpot fabpot closed this as completed Sep 19, 2016
symfony-splitter pushed a commit to symfony/dependency-injection that referenced this issue Sep 19, 2016
…ions class when possible (Ener-Getick)

This PR was merged into the 3.2-dev branch.

Discussion
----------

[DependencyInjection] Automatically detect the definitions class when possible

| Q             | A
| ------------- | ---
| Branch?       | "master"
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | symfony/symfony#19161
| License       | MIT
| Doc PR        |

> Thanks to the features of php 7.0 we can now guess the class of a service created with a factory:
> ```php
> function myFactory(): MyServiceClass
> {
> }
> ```
>
> So I propose to create a new pass to automatically update the services definition when possible. This is particularly useful for autowiring (this way you don't have to copy-paste the class name of the service, especially when this is from a third party library).
>
> What do you think ?

Commits
-------

63afe3c [DependencyInjection] Automatically detect the definitions class when possible
@TomasVotruba
Copy link
Contributor

Thank you @fabpot and @Ener-Getick

@GuilhemN
Copy link
Contributor Author

You're welcome :)

fabpot added a commit that referenced this issue Oct 21, 2016
…n PassConfig (hason)

This PR was merged into the 3.2-dev branch.

Discussion
----------

[DependencyInjection] Fix FactoryReturnTypePass position in PassConfig

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

Commits
-------

dfb5cc3 [DependencyInjection] Fix FactoryReturnTypePass position in PassConfig
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DependencyInjection Feature RFC RFC = Request For Comments (proposals about features that you want to be discussed)
Projects
None yet
Development

No branches or pull requests

4 participants