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

[5.7] [Option 2] Improve PSR-11 implementation #25871

Closed
wants to merge 2 commits into from

Conversation

deleugpn
Copy link
Contributor

@deleugpn deleugpn commented Oct 2, 2018

Same description of #25870, but with the following differences:

  • A simpler implementation with less feedback.
  • The PSR-11 user will not be able to differentiate a NotFoundExceptionInterface from a ContainerExceptionInterface.

The Usage for this one would be as follows. The container might throw ReflectionException when the identifier is not a class name. Although this would not be fully compatible with PSR-11, it would still give a lot more benefit when using the container than the current implementation.

function (ContainerInterface $container) {
    // ...

    try {
        $class = $container->get($identifier);
    } catch (ContainerExceptionInterface | ReflectionException $e) 
        // Cannot resolve $identifier
    } 
}

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

Successfully merging this pull request may close these issues.

2 participants