16
16
use Symfony \Component \DependencyInjection \Definition ;
17
17
use Symfony \Component \DependencyInjection \Exception \InvalidArgumentException ;
18
18
use Symfony \Component \DependencyInjection \Exception \InvalidParameterTypeException ;
19
+ use Symfony \Component \DependencyInjection \Exception \RuntimeException ;
19
20
use Symfony \Component \DependencyInjection \Parameter ;
20
21
use Symfony \Component \DependencyInjection \Reference ;
21
22
use Symfony \Component \DependencyInjection \ServiceLocator ;
@@ -37,24 +38,22 @@ final class CheckTypeDeclarationsPass extends AbstractRecursivePass
37
38
private const SCALAR_TYPES = ['int ' , 'float ' , 'bool ' , 'string ' ];
38
39
39
40
private $ autoload ;
40
- private $ ignoredServices ;
41
41
42
42
/**
43
43
* @param bool $autoload Whether services who's class in not loaded should be checked or not.
44
44
* Defaults to false to save loading code during compilation.
45
45
*/
46
- public function __construct (bool $ autoload = false , array $ ignoredServices = [] )
46
+ public function __construct (bool $ autoload = false )
47
47
{
48
48
$ this ->autoload = $ autoload ;
49
- $ this ->ignoredServices = array_flip ($ ignoredServices );
50
49
}
51
50
52
51
/**
53
52
* {@inheritdoc}
54
53
*/
55
54
protected function processValue ($ value , $ isRoot = false )
56
55
{
57
- if (!$ value instanceof Definition || isset ( $ this -> ignoredServices [ $ this -> currentId ] )) {
56
+ if (!$ value instanceof Definition || $ value -> hasErrors ( )) {
58
57
return parent ::processValue ($ value , $ isRoot );
59
58
}
60
59
@@ -71,7 +70,15 @@ protected function processValue($value, $isRoot = false)
71
70
}
72
71
73
72
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
+ }
75
82
76
83
$ this ->checkTypeDeclarations ($ value , $ reflectionMethod , $ methodCall [1 ]);
77
84
}
0 commit comments