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 922885c

Browse filesBrowse files
Wojciech Gorczycafabpot
Wojciech Gorczyca
authored andcommitted
[DI] Fixed wrong factory method in exception
1 parent 34c8a8b commit 922885c
Copy full SHA for 922885c

File tree

Expand file treeCollapse file tree

2 files changed

+22
-0
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+22
-0
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Compiler/ResolveNamedArgumentsPass.php
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ protected function processValue($value, $isRoot = false)
4949
if (null === $parameters) {
5050
$r = $this->getReflectionMethod($value, $method);
5151
$class = $r instanceof \ReflectionMethod ? $r->class : $this->currentId;
52+
$method = $r->getName();
5253
$parameters = $r->getParameters();
5354
}
5455

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveNamedArgumentsPassTest.php
+21Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@
1616
use Symfony\Component\DependencyInjection\ContainerBuilder;
1717
use Symfony\Component\DependencyInjection\Reference;
1818
use Symfony\Component\DependencyInjection\Tests\Fixtures\CaseSensitiveClass;
19+
use Symfony\Component\DependencyInjection\Tests\Fixtures\FactoryDummy;
1920
use Symfony\Component\DependencyInjection\Tests\Fixtures\NamedArgumentsDummy;
2021
use Symfony\Component\DependencyInjection\Tests\Fixtures\NamedArgumentsVariadicsDummy;
2122
use Symfony\Component\DependencyInjection\Tests\Fixtures\SimilarArgumentsDummy;
23+
use Symfony\Component\DependencyInjection\Tests\Fixtures\TestDefinition1;
2224

2325
/**
2426
* @author Kévin Dunglas <dunglas@gmail.com>
@@ -103,6 +105,7 @@ public function testClassNoConstructor()
103105

104106
/**
105107
* @expectedException \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException
108+
* @expectedExceptionMessage Invalid service "Symfony\Component\DependencyInjection\Tests\Fixtures\NamedArgumentsDummy": method "__construct()" has no argument named "$notFound". Check your service definition.
106109
*/
107110
public function testArgumentNotFound()
108111
{
@@ -115,6 +118,24 @@ public function testArgumentNotFound()
115118
$pass->process($container);
116119
}
117120

121+
/**
122+
* @expectedException \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException
123+
* @expectedExceptionMessage Invalid service "Symfony\Component\DependencyInjection\Tests\Fixtures\TestDefinition1": method "Symfony\Component\DependencyInjection\Tests\Fixtures\FactoryDummy::create()" has no argument named "$notFound". Check your service definition.
124+
*/
125+
public function testCorrectMethodReportedInException()
126+
{
127+
$container = new ContainerBuilder();
128+
129+
$container->register(FactoryDummy::class, FactoryDummy::class);
130+
131+
$definition = $container->register(TestDefinition1::class, TestDefinition1::class);
132+
$definition->setFactory(array(FactoryDummy::class, 'create'));
133+
$definition->setArguments(array('$notFound' => '123'));
134+
135+
$pass = new ResolveNamedArgumentsPass();
136+
$pass->process($container);
137+
}
138+
118139
public function testTypedArgument()
119140
{
120141
$container = new ContainerBuilder();

0 commit comments

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