Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add generics to ContainerInterface#44

Open
nicolas-grekas wants to merge 1 commit into
php-fig:master from
nicolas-grekas:patch-1
Open

Add generics to ContainerInterface #44
nicolas-grekas wants to merge 1 commit into
php-fig:master from
nicolas-grekas:patch-1

Conversation

@nicolas-grekas

@nicolas-grekas nicolas-grekas commented May 5, 2022

Copy link
Copy Markdown

WDYT?

gpn273, ArtARTs36, Koc, andrew-demb, JoshuaBehrens, and chalasr reacted with thumbs up emoji

mnapoli commented May 5, 2022

Copy link
Copy Markdown
Member

Duplicates #35?

nicolas-grekas commented May 5, 2022
edited
Loading

Copy link
Copy Markdown
Author

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:
ContainerInterface<Foo> $container->get('bar')->... and be suggested with what Foo provides.

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 of mixed.

ro0NL

This comment was marked as outdated.

nicolas-grekas added a commit to symfony/symfony that referenced this pull request May 7, 2022
...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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

1 more reviewer

@ro0NL ro0NL ro0NL approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /