8000 bug #34562 [DI] Skip unknown method calls for factories in check type… · symfony/symfony@8378d95 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8378d95

Browse files
bug #34562 [DI] Skip unknown method calls for factories in check types pass (fancyweb)
This PR was merged into the 4.4 branch. Discussion ---------- [DI] Skip unknown method calls for factories in check types pass | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | #34559 | License | MIT | Doc PR | - Ref #30885 and #30889. Commits ------- 592bff8 [DI] Skip unknown method calls for factories in check types pass
2 parents 8d22819 + 592bff8 commit 8378d95

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/TestBundle.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,6 @@ public function process(ContainerBuilder $container)
4949
}
5050
});
5151

52-
$container->addCompilerPass(new CheckTypeDeclarationsPass(true, ['http_client', '.debug.http_client']), PassConfig::TYPE_AFTER_REMOVING, -100);
52+
$container->addCompilerPass(new CheckTypeDeclarationsPass(true), PassConfig::TYPE_AFTER_REMOVING, -100);
5353
}
5454
}

src/Symfony/Bundle/FrameworkBundle/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"ext-xml": "*",
2121
"symfony/cache": "^4.4|^5.0",
2222
"symfony/config": "^4.3.4|^5.0",
23-
"symfony/dependency-injection": "^4.4|^ 8000 5.0",
23+
"symfony/dependency-injection": "^4.4.1|^5.0.1",
2424
"symfony/http-foundation": "^4.4|^5.0",
2525
"symfony/http-kernel": "^4.4",
2626
"symfony/polyfill-mbstring": "~1.0",

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

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Symfony\Component\DependencyInjection\Definition;
1717
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
1818
use Symfony\Component\DependencyInjection\Exception\InvalidParameterTypeException;
19+
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
1920
use Symfony\Component\DependencyInjection\Parameter;
2021
use Symfony\Component\DependencyInjection\Reference;
2122
use Symfony\Component\DependencyInjection\ServiceLocator;
@@ -37,24 +38,22 @@ final class CheckTypeDeclarationsPass extends AbstractRecursivePass
3738
private const SCALAR_TYPES = ['int', 'float', 'bool', 'string'];
3839

3940
private $autoload;
40-
private $ignoredServices;
4141

4242
/**
4343
* @param bool $autoload Whether services who's class in not loaded should be checked or not.
4444
* Defaults to false to save loading code during compilation.
4545
*/
46-
public function __construct(bool $autoload = false, array $ignoredServices = [])
46+
public function __construct(bool $autoload = false)
4747
{
4848
$this->autoload = $autoload;
49-
$this->ignoredServices = array_flip($ignoredServices);
5049
}
5150

5251
/**
5352
* {@inheritdoc}
5453
*/
5554
protected function processValue($value, $isRoot = false)
5655
{
57-
if (!$value instanceof Definition || isset($this->ignoredServices[$this->currentId])) {
56+
if (!$value instanceof Definition || $value->hasErrors()) {
5857
return parent::processValue($value, $isRoot);
5958
}
6059

@@ -71,7 +70,15 @@ protected function processValue($value, $isRoot = false)
7170
}
7271

7372
foreach ($value->getMethodCalls() as $methodCall) {
74-
$reflectionMethod = $this->getReflectionMethod($value, $methodCall[0]);
73+
try {
74+
$reflectionMethod = $this->getReflectionMethod($value, $methodCall[0]);
75+
} catch (RuntimeException $e) {
76+
if ($value->getFactory()) {
77+
continue;
78+
}
79+
80+
throw $e;
81+
}
7582

7683
$this->checkTypeDeclarations($value, $reflectionMethod, $methodCall[1]);
7784
}

0 commit comments

Comments
 (0)
0