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 592bff8

Browse filesBrowse files
fancywebnicolas-grekas
authored andcommitted
[DI] Skip unknown method calls for factories in check types pass
1 parent a8a9e69 commit 592bff8
Copy full SHA for 592bff8

File tree

3 files changed

+14
-7
lines changed
Filter options

3 files changed

+14
-7
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/TestBundle.php
+1-1Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/composer.json
+1-1Lines 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|^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

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Compiler/CheckTypeDeclarationsPass.php
+12-5Lines 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)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.