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

Add test case to show shortcomings of nesting & factory #52

Closed
wants to merge 3 commits into from

Conversation

SamMousa
Copy link
Contributor

This shows that nesting doesn't work as expected since we're losing scope as soon as we pass the request on to the parent.

@SamMousa
Copy link
Contributor Author

https://github.com/container-interop/fig-standards/blob/master/proposed/container-meta.md#7-delegate-lookup-feature

At the very least we should clearly and explicitly document what choices we have made regarding delegated lookups.

@SamMousa
Copy link
Contributor Author

PHP-DI solves it by passing the parent into the child as well, that way the child can resolve dependencies via the parent: https://github.com/PHP-DI/PHP-DI/blob/master/src/Container.php#L96

Some more reading: https://thecodingmachine.io/psr-11-an-in-depth-view-at-the-delegate-lookup-feature

@SamMousa SamMousa changed the title Add test case to show shortcomings of nesting Add test case to show shortcomings of nesting & factory Oct 25, 2018
@samdark
Copy link
Member

samdark commented Oct 25, 2018

We choose to support delegate lookups with fallback strategy: if there's no service registered in a container it is being checked in its parent.

@SamMousa
Copy link
Contributor Author

Yeah, but fallback should resolve child dependencies in the root container.

We could create a simple composite container for this purpose. I'll do some more research

@samdark
Copy link
Member

samdark commented Oct 25, 2018

Yeah, but fallback should resolve child dependencies in the root container.

Correct.

@samdark samdark added the type:bug Bug label Oct 25, 2018
@SamMousa
Copy link
Contributor Author

That problem (I think) is hard to solve with parent container approach (which creates trees). Instead we should implement a composite container 😵 I'll think on this and make a PR next week.

@samdark
Copy link
Member

samdark commented Oct 25, 2018

Alternatively we can remove support for container nesting altogether. I was thinking about using it for modules initially but still not sure about it.

@SamMousa
Copy link
Contributor Author

Even better. We can always implement it if we need it in the future.

@SamMousa
Copy link
Contributor Author

On the other hand, if we have a composite container that could be a simple way to implement overrides *-)

@samdark
Copy link
Member

samdark commented Oct 25, 2018

Well, check it if you want to but don't spend too much time on it. We don't depend on this feature much and can live w/o it.

@hiqsol
Copy link
Member

hiqsol commented Oct 25, 2018

Parenting is already used to have factory container as a child of main container.
But afaics it is not really used in core or elsewhere.

- |
vendor/bin/phpcs --standard=PSR2 src tests &&
vendor/bin/phpunit $PHPUNIT_FLAGS
- vendor/bin/phpcs --standard=PSR2 src tests
Copy link
Member

Choose a reason for hiding this comment

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

There's no need for it. Scrutinizer has PSR2 rules built-in.

@samdark
Copy link
Member

samdark commented Jul 6, 2019

Seems to be no longer valid.

@samdark samdark closed this Jul 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants