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

Update Migration Guide for v2 #466

Closed
RalfEggert opened this issue Mar 12, 2017 · 4 comments
Closed

Update Migration Guide for v2 #466

RalfEggert opened this issue Mar 12, 2017 · 4 comments

Comments

@RalfEggert
Copy link
Contributor

Please note this issue: zendframework/zend-servicemanager#184

Due to this chapter of the migration guide I started to refactor my factories:

http://zendframework.github.io/zend-expressive/reference/migration/to-v2/#psr-11-support

Some of them broke since they depend on the $requestName and $options parameters.

@geerteltink
Copy link
Member

It's mentioned in the zend-servicemanager docs. You can leave those alone until zend-servicemanager v4 is released or use the mentioned workaround:

use a callable with the following signature:

function (
    \Psr\Container\ContainerInterface $container,
    string $requestedName,
    array $options = null
)

I'm not sure if we need to add all "edge cases" to the docs if it's mentioned already in the packages itself.

@RalfEggert
Copy link
Contributor Author

Well, I just followed the migration guide and started to switch the ContainerInterface and then the factories broke since I always use the Zend\ServiceManager\Factory\FactoryInterface. So I reverted the change. At least as small hint would keep other users from stepping in the same trap.

@weierophinney
Copy link
Member

@RalfEggert This is a case where you need to consider which container you are using.

If you are not implementing the zend-servicemanager interface(s) when creating factories (the approach we have taken within Expressive and its libraries, as well as the skeleton, in order to keep them container-agnostic), then you can safely change typehints. If you are implementing an interface from another package, you need to check that package before making changes to your signatures.

In your case, you were clearly using zend-servicemanager, as you were creating zend-servicemanager interface implementations. As such, you need to consult the zend-servicemanager documentation to see what you need to do to migrate.

For that, we already have a page:

And it covers this scenario already.

The only documentation I can think of would be a note:

If you are implementing interfaces from other packages in your factory implementations, be sure to check and see if those interfaces update to PSR-11 before making changes.

Would that "solve" the issue for you?

@RalfEggert
Copy link
Contributor Author

Yeah, that simple sentence would lead the users in the right direction and solve this issue.

👍

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

No branches or pull requests

3 participants