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

Allow knowledge of variadic callables #6

Closed
philipobenito opened this issue Jan 13, 2015 · 1 comment
Closed

Allow knowledge of variadic callables #6

philipobenito opened this issue Jan 13, 2015 · 1 comment
Assignees
Milestone

Comments

@philipobenito
Copy link
Member

Considering the new Container::call functionality, I feel there should be a way to pass concrete runtime arguments to the callable separately to the dependencies that are defined.

It doesn't necessarily need to be >5.6 only, the callable would simply need to define the correct amount of arguments.

< PHP 5.6

$container->invokable('some_callable', function (SomeDependency $somedependency, $variadic1, $variadic2) {
    // ...
})->withArgument('SomeDependency');

$container->call('some_callable', ['variadic1 value', 'variadic2 value']);

>= PHP 5.6

$container->invokable('some_callable', function (SomeDependency $somedependency, ...$params) {
    // ...
})->withArgument('SomeDependency');

$container->call('some_callable', ['variadic1 value', 'variadic2 value']);

The main motivation behind this is to be able to use Container::call within a strategy for League\Route, allowing for dependencies to be defined per controller action but still pass in values from wildcard segments of the URI.

@philipobenito philipobenito self-assigned this Jan 13, 2015
@philipobenito philipobenito modified the milestone: 1.2.0 Jan 13, 2015
@philipobenito
Copy link
Member Author

This currently works when reflecting on callable arguments, however is inconsistent when not using reflection, provide a more consistent solution that will work across the board.

@philipobenito philipobenito added this to the 1.4.0 milestone Mar 1, 2015
localheinz pushed a commit to localheinz/container that referenced this issue Sep 21, 2023
Move exceptions to the main namespace
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant