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

Better type safety in container #1425

Open
ciaranmcnulty opened this issue Mar 17, 2022 · 0 comments
Open

Better type safety in container #1425

ciaranmcnulty opened this issue Mar 17, 2022 · 0 comments

Comments

@ciaranmcnulty
Copy link
Member

we retrieve services by string key, which is inherently type unsafe

$foo = $container->get('my.service'); // what type is $foo?

It would be good to migrate to PSR-style where class names are used:

$foo = $container->get(Foo::class); // it is a Foo

An intermediate step might be to add an (optional?) type check parameter

$foo = $container->get('my.service', Foo::class); // error if the registered service is not Foo
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