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

Incorrect work of FactoryProvider->has() #104

Closed
roxblnfk opened this issue Feb 13, 2020 · 1 comment
Closed

Incorrect work of FactoryProvider->has() #104

roxblnfk opened this issue Feb 13, 2020 · 1 comment
Labels

Comments

@roxblnfk
Copy link
Member

README.MD: # Using deferred service providers [link]

// returns false as provider wasn't registered
$container->has(EngineInterface::class); 

// returns SolarEngine, registered in the provider
$engine = $container->get(EngineInterface::class); 

// returns true as provider was registered when EngineInterface was requested from the container
$container->has(EngineInterface::class); 

PSR about has():

1.1.2 Reading from a container
has takes one unique parameter: an entry identifier, which MUST be a string. has MUST return true if an entry identifier is known to the container and false if it is not. If has($id) returns false, get($id) MUST throw a NotFoundExceptionInterface.

3.1. Psr\Container\ContainerInterface

    /**
     * Returns true if the container can return an entry for the given identifier.
     * Returns false otherwise.
     *
     * `has($id)` returning true does not mean that `get($id)` will not throw an exception.
     * It does however mean that `get($id)` will not throw a `NotFoundExceptionInterface`.
     *
     * @param string $id Identifier of the entry to look for.
     *
     * @return bool
     */
    public function has($id);

Method get() must returns true if the container can return an entry for the given identifier.
In our case, it returns false until the first call to get()

@roxblnfk roxblnfk changed the title Incorrect work of Factoryprovider->has() Incorrect work of FactoryProvider->has() Feb 13, 2020
@samdark samdark added the type:test Test label Feb 14, 2020
@samdark
Copy link
Member

samdark commented Feb 14, 2020

Need to cover it with unit test...

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

No branches or pull requests

2 participants