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

Removed $checkAbstractFactories flag from has() #49

Merged
merged 2 commits into from
Nov 5, 2015

Conversation

weierophinney
Copy link
Member

In updating zend-mvc to v3 of zend-servicemanager, I ran into a subtle issue: has() does not look in abstract factories by default, and requires that you pass an additional flag, $checkAbstractFactories, with a boolean true value, if you want to test if an abstract factory can resolve the given $name.

This breaks the Liskov Substitution Principal, as it means that the behavior of has() depends on how the ServiceManager is configured. Users then must be aware that an abstract factory might supply a dependency, and cannot rely on has() per the container-interop contract to work for the specific use case of zend-servicemanager.

As such, this patch removes the flag, and checks abstract factories whenever a service or factory matching the provided $name is not found.

The flag breaks the LSP, and requires that a user know how a given
service might be configured inside the container. Removing it provides
easier interoperability, and removes unexpected false negative lookups.
@weierophinney weierophinney added this to the 3.0.0 milestone Nov 4, 2015
@weierophinney
Copy link
Member Author

Ping @bakura10 … (ignore #48)

- As this patch makes it obsolete.
@bakura10
Copy link
Contributor

bakura10 commented Nov 4, 2015

+1 for this change. This makes the signature coherent with container-interop contract, and as said in the other, the performance penalty will be negligeable anyway.

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

Successfully merging this pull request may close these issues.

3 participants