Skip to content

Commit 3810804

Browse files
committed
PhpStormStubsSourceStubber AstLocator - use PHP 8 parser
1 parent 459f5dd commit 3810804

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

conf/config.neon

+1
Original file line numberDiff line numberDiff line change
@@ -1283,6 +1283,7 @@ services:
12831283
class: PHPStan\Reflection\BetterReflection\BetterReflectionSourceLocatorFactory
12841284
arguments:
12851285
parser: @phpParserDecorator
1286+
php8Parser: @php8PhpParser
12861287
autoloadDirectories: %autoload_directories%
12871288
autoloadFiles: %autoload_files%
12881289
scanFiles: %scanFiles%

src/Reflection/BetterReflection/BetterReflectionSourceLocatorFactory.php

+10-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ class BetterReflectionSourceLocatorFactory
2929
/** @var \PhpParser\Parser */
3030
private $parser;
3131

32+
/** @var \PhpParser\Parser */
33+
private $php8Parser;
34+
3235
/** @var PhpStormStubsSourceStubber */
3336
private $phpstormStubsSourceStubber;
3437

@@ -90,6 +93,7 @@ class BetterReflectionSourceLocatorFactory
9093
*/
9194
public function __construct(
9295
\PhpParser\Parser $parser,
96+
\PhpParser\Parser $php8Parser,
9397
PhpStormStubsSourceStubber $phpstormStubsSourceStubber,
9498
ReflectionSourceStubber $reflectionSourceStubber,
9599
OptimizedSingleFileSourceLocatorRepository $optimizedSingleFileSourceLocatorRepository,
@@ -109,6 +113,7 @@ public function __construct(
109113
)
110114
{
111115
$this->parser = $parser;
116+
$this->php8Parser = $php8Parser;
112117
$this->phpstormStubsSourceStubber = $phpstormStubsSourceStubber;
113118
$this->reflectionSourceStubber = $reflectionSourceStubber;
114119
$this->optimizedSingleFileSourceLocatorRepository = $optimizedSingleFileSourceLocatorRepository;
@@ -165,7 +170,11 @@ public function create(): SourceLocator
165170
return $this->container->getService('betterReflectionFunctionReflector');
166171
});
167172

168-
$locators[] = new SkipClassAliasSourceLocator(new PhpInternalSourceLocator($astLocator, $this->phpstormStubsSourceStubber));
173+
$astPhp8Locator = new Locator($this->php8Parser, function (): FunctionReflector {
174+
return $this->container->getService('betterReflectionFunctionReflector');
175+
});
176+
177+
$locators[] = new SkipClassAliasSourceLocator(new PhpInternalSourceLocator($astPhp8Locator, $this->phpstormStubsSourceStubber));
169178
$locators[] = new ClassBlacklistSourceLocator($this->autoloadSourceLocator, $this->staticReflectionClassNamePatterns);
170179
foreach ($this->composerAutoloaderProjectPaths as $composerAutoloaderProjectPath) {
171180
$locator = $this->composerJsonAndInstalledJsonSourceLocatorMaker->create($composerAutoloaderProjectPath);

0 commit comments

Comments
 (0)