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

Container compilation and delegators #52

Closed
karsten-sbs opened this issue Dec 18, 2021 · 3 comments · Fixed by #54
Closed

Container compilation and delegators #52

karsten-sbs opened this issue Dec 18, 2021 · 3 comments · Fixed by #54
Assignees
Labels
enhancement New feature or request

Comments

@karsten-sbs
Copy link

karsten-sbs commented Dec 18, 2021

I use several delegators in my project and if I define Config::DI_CACHE_PATH I get the error

Cannot compile closures which import variables using the use keyword
as mentioned in issue #45. The solution mentioned there isn't practicable in my case. I'd like to propose the following change to the Config class which eliminates the problem with the use keyword (and allows for type hinting the parameters):

                $current                      =
                    factory(function (ContainerInterface $container, RequestedEntry $requestedEntry, string $delegator, string $previous, string $name) {
                        $factory  = new $delegator();
                        $callable = function () use ($previous, $container) {
                            return $container->get($previous);
                        };
                        return $factory($container, $name, $callable);
                    })->parameter('delegator', $delegator)
                      ->parameter('previous', $previous)
                      ->parameter('name', $name);
@elie29
Copy link
Owner

elie29 commented Dec 27, 2021

@karsten-sbs could you make the change and create a PR please? thx

@elie29 elie29 added the enhancement New feature or request label Dec 27, 2021
@karsten-sbs
Copy link
Author

Happy New Year, @elie29! I created a PR with my global account.

@elie29
Copy link
Owner

elie29 commented Jan 13, 2022

@karsten-sbs happy new year, I will check it as soon as possible. Thank you

@elie29 elie29 mentioned this issue Jan 18, 2022
@elie29 elie29 linked a pull request Jan 18, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants