8000 Do not check errored definitions’s type · symfony/symfony@ccf9224 · GitHub
[go: up one dir, main page]

Skip to content

Commit ccf9224

Browse files
committed
Do not check errored definitions’s type
1 parent f1122a2 commit ccf9224

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

src/Symfony/Component/DependencyInjection/Compiler/CheckTypeDeclarationsPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ private function checkType(Definition $checkedDefinition, $value, \ReflectionPar
210210
$class = null;
211211

212212
if ($value instanceof Definition) {
213-
if ($value->getFactory()) {
213+
if ($value->hasErrors() || $value->getFactory()) {
214214
return;
215215
}
216216

src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckTypeDeclarationsPassTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
use Symfony\Component\DependencyInjection\ParameterBag\EnvPlaceholderParameterBag;
2424
use Symfony\Component\DependencyInjection\Reference;
2525
use Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\Bar;
26+
use Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\BarErroredDependency;
2627
use Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\BarMethodCall;
2728
use Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\BarOptionalArgument;
2829
use Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\BarOptionalArgumentNotNull;
@@ -1010,6 +1011,20 @@ public function testIgnoreDefinitionFactoryArgument()
10101011

10111012
$this->addToAssertionCount(1);
10121013
}
1014+
1015+
public function testErroredDefinitionsAreNotChecked()
1016+
{
1017+
$container = new ContainerBuilder();
1018+
$container->register('errored_dependency', BarErroredDependency::class)
1019+
->setArguments([
1020+
(new Definition(Foo::class))
1021+
->addError('error'),
1022+
]);
1023+
1024+
(new CheckTypeDeclarationsPass(true))->process($container);
1025+
1026+
$this->addToAssertionCount(1);
1027+
}
10131028
}
10141029

10151030
class CallableClass
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
namespace Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass;
4+
5+
class BarErroredDependency
6+
{
7+
public function __construct(\stdClass $foo)
8+
{
9+
}
10+
}

0 commit comments

Comments
 (0)
0