-
Notifications
You must be signed in to change notification settings - Fork 53
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
Add generics to ContainerInterface #44
base: master
Are you sure you want to change the base?
Conversation
Duplicates #35? |
Quite close indeed. I'd just not add generics to the keys. Despite #35 being closed, I still think this would be a good idea. Locators scoped to some interface are quite common. It'd be great to hint autocompletion about them: The fact that psalm/phpstan would complain about this shouldn't be a blocker to me. Eg they could stop complaining when the template type is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
psalm will also complain about missing template params when extending ContainerInterface, expecting 1
which is kinda weird due of mixed
implying a default type (proven by template-less arguments https://psalm.dev/r/da9d16aecc)
phpstan still requires a type for arguments https://phpstan.org/r/9dc90c25-c7ab-4117-a686-91c060627217
nevertheless
to clarify, TS is super explicit here :) |
…face (nicolas-grekas) This PR was merged into the 6.1 branch. Discussion ---------- [Contracts/Service] Add generics to ServiceProviderInterface | Q | A | ------------- | --- | Branch? | 6.1 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - Should allow using `ServiceProviderInterface<MyInterface>` and have autocompletion when doing `$provider->get->...`. Submitted upstream as php-fig/container#44 Commits ------- 2aa459a [Contracts/Service] Add generics to ServiceProviderInterface
WDYT?