Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 83d05b8

Browse filesBrowse files
committed
fix check miss on variadic
1 parent b563760 commit 83d05b8
Copy full SHA for 83d05b8

File tree

Expand file treeCollapse file tree

2 files changed

+19
-5
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+19
-5
lines changed

‎src/Symfony/Component/DependencyInjection/Compiler/CheckTypeHintsPass.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Compiler/CheckTypeHintsPass.php
+1-5Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,8 @@ private function checkArgumentsTypeHints(\ReflectionFunctionAbstract $reflection
8282
$reflectionParameters = $reflectionFunction->getParameters();
8383
$checksCount = min($reflectionFunction->getNumberOfParameters(), count($configurationArguments));
8484

85-
if ($reflectionFunction->isVariadic()) {
86-
--$checksCount;
87-
}
88-
8985
for ($i = 0; $i < $checksCount; ++$i) {
90-
if (!$reflectionParameters[$i]->hasType()) {
86+
if (!$reflectionParameters[$i]->hasType() || $reflectionParameters[$i]->isVariadic()) {
9187
continue;
9288
}
9389

‎src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckTypeHintsPassTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckTypeHintsPassTest.php
+18Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,24 @@ public function testProcessVariadicFails()
145145
(new CheckTypeHintsPass(true))->process($container);
146146
}
147147

148+
/**
149+
* @expectedException \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException
150+
* @expectedExceptionMessage Invalid definition for service "bar": argument 0 of "Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeHintsPass\BarMethodCall::setFoosVariadic" requires a "Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeHintsPass\Foo", "stdClass" passed
151+
*/
152+
public function testProcessVariadicFailsOnPassingBadTypeOnAnotherArgument()
153+
{
154+
$container = new ContainerBuilder();
155+
156+
$container->register('stdClass', \stdClass::class);
157+
$container->register('foo', Foo::class);
158+
$container->register('bar', BarMethodCall::class)
159+
->addMethodCall('setFoosVariadic', array(
160+
new Reference('stdClass'),
161+
));
162+
163+
(new CheckTypeHintsPass(true))->process($container);
164+
}
165+
148166
public function testProcessVariadicSuccess()
149167
{
150168
$container = new ContainerBuilder();

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.