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

[Feature Request] Overriding dynamic service return types #301

Open
keulinho opened this issue Aug 15, 2022 · 0 comments
Open

[Feature Request] Overriding dynamic service return types #301

keulinho opened this issue Aug 15, 2022 · 0 comments

Comments

@keulinho
Copy link

Currently there is no way to override dynamic service return types on the container that are specified in ServiceDynamicReturnTypeExtension.

This is useful to provide more specific information e.g. if the service implement a generic class there is currently no way to teach phpstan that a specific service is of a specific type.

I already build a custom DynamicMethodReturnTypeExtension that adds the generic types, but in the end phpstan makes a union for all types returned by any DynamicMethodReturnTypeExtension. This leads to the less specific type of the smyfony extension "winning" and in fact overriding my more specific type again.

I would like to the a feature where you can specify the phpstan type of a service, or at least mark a service to be ignored by the symfony phpstan extension, so you can write your custom DynamicMethodReturnTypeExtension for those services.

Happy to contribute such a feature, but I'm currently not sure how to best implement this. The only way I see now is adding a custom tag to the service definition and specifying the type there and that type will then take precedence over the class name of the service.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant