diff --git a/src/DI/Resolver.php b/src/DI/Resolver.php index 6db64d5f8..15ec7db1a 100644 --- a/src/DI/Resolver.php +++ b/src/DI/Resolver.php @@ -690,7 +690,7 @@ private static function isArrayOf(\ReflectionParameter $parameter, ?Nette\Utils\ && $type && $type->getSingleName() === 'array' && preg_match( - '#@param[ \t]+(?|([\w\\\\]+)\[\]|array)[ \t]+\$' . $parameter->name . '#', + '#@param[ \t]+(?|([\w\\\\]+)\[\]|list<([\w\\\\]+)>|array)[ \t]+\$' . $parameter->name . '#', (string) $method->getDocComment(), $m ) diff --git a/tests/DI/ContainerBuilder.autowiring.type[].phpt b/tests/DI/ContainerBuilder.autowiring.type[].phpt index 4f3f595b6..351b370a7 100644 --- a/tests/DI/ContainerBuilder.autowiring.type[].phpt +++ b/tests/DI/ContainerBuilder.autowiring.type[].phpt @@ -16,18 +16,21 @@ require __DIR__ . '/../bootstrap.php'; class Foo { public $bars; + public $waldos; public $foos; public $strings; /** * @param Service[] $bars + * @param list $waldos * @param array $foos * @param string[] $strings */ - public function __construct(array $bars = [], ?array $foos = null, array $strings = ['default']) + public function __construct(array $bars = [], array $waldos = [], ?array $foos = null, array $strings = ['default']) { $this->bars = $bars; + $this->waldos = $waldos; $this->foos = $foos; $this->strings = $strings; } @@ -67,6 +70,11 @@ Assert::same([ $container->getService('s2'), $container->getService('s3'), ], $foo->bars); +Assert::same([ + $container->getService('s1'), + $container->getService('s2'), + $container->getService('s3'), +], $foo->waldos); Assert::same([], $foo->foos); Assert::same(['default'], $foo->strings); @@ -80,5 +88,10 @@ Assert::same([ $container->getService('s2'), $container->getService('s3'), ], $foo2->bars); +Assert::same([ + $container->getService('s1'), + $container->getService('s2'), + $container->getService('s3'), +], $foo2->waldos); Assert::same([$foo], $foo2->foos); // difference Assert::same(['default'], $foo2->strings);