33namespace PHPStan \DependencyInjection ;
44
55use Nette \DI \CompilerExtension ;
6- use Nette \DI \Definitions \ServiceDefinition ;
76use Override ;
8- use PHPStan \Analyser \Analyser ;
97use PHPStan \Analyser \Fiber \FiberNodeScopeResolver ;
10- use PHPStan \Analyser \FileAnalyser ;
11- use PHPStan \ShouldNotHappenException ;
8+ use PHPStan \Analyser \NodeScopeResolver ;
129use function getenv ;
1310
1411final class FnsrExtension extends CompilerExtension
@@ -23,17 +20,11 @@ public function beforeCompile()
2320 }
2421
2522 $ builder = $ this ->getContainerBuilder ();
26- $ analyserDef = $ builder ->getDefinitionByType (Analyser::class);
27- if (!$ analyserDef instanceof ServiceDefinition) {
28- throw new ShouldNotHappenException ();
29- }
30- $ analyserDef ->setArgument ('nodeScopeResolver ' , '@ ' . FiberNodeScopeResolver::class);
23+ $ nodeScopeResolverDef = $ builder ->getDefinitionByType (NodeScopeResolver::class);
24+ $ nodeScopeResolverDef ->setAutowired (false );
3125
32- $ fileAnalyserDef = $ builder ->getDefinitionByType (FileAnalyser::class);
33- if (!$ fileAnalyserDef instanceof ServiceDefinition) {
34- throw new ShouldNotHappenException ();
35- }
36- $ fileAnalyserDef ->setArgument ('nodeScopeResolver ' , '@ ' . FiberNodeScopeResolver::class);
26+ $ fiberNodeScopeResolverDef = $ builder ->getDefinitionByType (FiberNodeScopeResolver::class);
27+ $ fiberNodeScopeResolverDef ->setAutowired ([NodeScopeResolver::class, FiberNodeScopeResolver::class]);
3728 }
3829
3930}
0 commit comments