You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
then both services are passed in. But if I change the method signature to this:
public function setLetters(...$letters) {
Then $letters is an array with only the first service.
Full test code:
<?php
require 'vendor/autoload.php';
$container = new DI\Container([
'alpha' => DI\create(Alpha::class),
'beta' => DI\create(Beta::class),
'letters' => DI\create(Letters::class)
->method(
'setLettersList',
DI\get('alpha'),
DI\get('beta'),
)
->method(
'setLettersSplat',
DI\get('alpha'),
DI\get('beta'),
),
]);
class Alpha {}
class Beta {}
class Letters {
public function setLettersList($alpha, $beta) {
dump(__METHOD__);
dump(func_get_args());
}
public function setLettersSplat(...$letters) {
// Should also get all the letters, but only gets the first one.
dump(__METHOD__);
dump(func_get_args());
}
}
$letters = $container->get('letters');
The text was updated successfully, but these errors were encountered:
ObjectCreator::injectMethodsAndProperties() seems to be correctly getting $args in both cases, which makes it look like the problem is when the method is invoked here:
$methodReflection->invokeArgs($object, $args);
But doing that directly on the objects works properly:
$letters = new Letters();
$methodReflection = new \ReflectionMethod($letters, 'setLettersSplat');
$args = [1, 2];
$methodReflection->invokeArgs($letters, $args);
If I do:
and
then both services are passed in. But if I change the method signature to this:
Then $letters is an array with only the first service.
Full test code:
The text was updated successfully, but these errors were encountered: