zendframework/zf2 — pull request #1698 by kokx (2012-07-02 00:01:15+00:00)
Title: ServiceManager::has() working correctly

This PR changes three things:

- ServiceManager::has() can now be relied upon. This is done by allowing only instances of AbstractFactoryInterface to be abstract factories (and not closures).
- Changed the AbstractFactoryInterface to also have the $requestedName parameter on the canCreateServiceWithName() method, because this was used in the ServiceManager itself. And also changed this in all the implementations.
- Created the canCreateServiceWithName() method on the DiAbstractServiceFactory. This so the ServiceManager::has() method can be relied upon.

The implementation of the DiAbstractServiceFactory::canCreateServiceWithName() method will only check if definitions or an instance exist in the Di. @Ocramius considered this to be the best thing to make the has() method for the Service Manager reliable.

I also did some refactorings, to rely on the has() method in some cases instead of trying to use the get() method and catching exceptions that might occur.