Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Update to ServiceManager to provide more precise error messages #4129

Conversation

BinaryKitten
Copy link
Contributor

When using any of the Plugin Managers, these all use the Abstract for get. Unfortunately this uses
__ METHOD __ to display when it can't find a service,

This leads to major confusion as the service manager may have that service set, but the child or plugin manager might not.

This updates to replace the Service manager name with the called class name so that instead of

Zend\ServiceManager\ServiceManager::get was unable to fetch or create an instance for ServiceRequested

you get

Zend\Form\FormElementManager::get was unable to fetch or create an instance for ServiceRequested

@@ -148,7 +148,7 @@ public function setShareByDefault($shareByDefault)
if ($this->allowOverride === false) {
throw new Exception\RuntimeException(sprintf(
'%s: cannot alter default shared service setting; container is marked immutable (allow_override is false)',
__METHOD__
str_replace(__CLASS__, get_called_class(), __METHOD__)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get_called_class() . '::' . __FUNCTION__ works too

@Ocramius
Copy link
Member

Huge +1 on this! It makes exception so much clearer!

Also, could you spot more of them?

@ghost ghost assigned weierophinney Mar 28, 2013
weierophinney added a commit that referenced this pull request Mar 28, 2013
Update to ServiceManager to provide more precise error messages
weierophinney added a commit that referenced this pull request Mar 28, 2013
weierophinney added a commit to zendframework/zend-servicemanager that referenced this pull request May 15, 2015
…/ServiceManagerErrorUpdate

Update to ServiceManager to provide more precise error messages
weierophinney added a commit to zendframework/zend-servicemanager that referenced this pull request May 15, 2015
weierophinney added a commit to zendframework/zend-servicemanager that referenced this pull request May 15, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants