Skip to content

Commit

Permalink
PhpStormStubsSourceStubber AstLocator - use PHP 8 parser
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Nov 1, 2020
1 parent 459f5dd commit 3810804
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions conf/config.neon
Original file line number Diff line number Diff line change
Expand Up @@ -1283,6 +1283,7 @@ services:
class: PHPStan\Reflection\BetterReflection\BetterReflectionSourceLocatorFactory
arguments:
parser: @phpParserDecorator
php8Parser: @php8PhpParser
autoloadDirectories: %autoload_directories%
autoloadFiles: %autoload_files%
scanFiles: %scanFiles%
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ class BetterReflectionSourceLocatorFactory
/** @var \PhpParser\Parser */
private $parser;

/** @var \PhpParser\Parser */
private $php8Parser;

/** @var PhpStormStubsSourceStubber */
private $phpstormStubsSourceStubber;

Expand Down Expand Up @@ -90,6 +93,7 @@ class BetterReflectionSourceLocatorFactory
*/
public function __construct(
\PhpParser\Parser $parser,
\PhpParser\Parser $php8Parser,
PhpStormStubsSourceStubber $phpstormStubsSourceStubber,
ReflectionSourceStubber $reflectionSourceStubber,
OptimizedSingleFileSourceLocatorRepository $optimizedSingleFileSourceLocatorRepository,
Expand All @@ -109,6 +113,7 @@ public function __construct(
)
{
$this->parser = $parser;
$this->php8Parser = $php8Parser;
$this->phpstormStubsSourceStubber = $phpstormStubsSourceStubber;
$this->reflectionSourceStubber = $reflectionSourceStubber;
$this->optimizedSingleFileSourceLocatorRepository = $optimizedSingleFileSourceLocatorRepository;
Expand Down Expand Up @@ -165,7 +170,11 @@ public function create(): SourceLocator
return $this->container->getService('betterReflectionFunctionReflector');
});

$locators[] = new SkipClassAliasSourceLocator(new PhpInternalSourceLocator($astLocator, $this->phpstormStubsSourceStubber));
$astPhp8Locator = new Locator($this->php8Parser, function (): FunctionReflector {
return $this->container->getService('betterReflectionFunctionReflector');
});

$locators[] = new SkipClassAliasSourceLocator(new PhpInternalSourceLocator($astPhp8Locator, $this->phpstormStubsSourceStubber));
$locators[] = new ClassBlacklistSourceLocator($this->autoloadSourceLocator, $this->staticReflectionClassNamePatterns);
foreach ($this->composerAutoloaderProjectPaths as $composerAutoloaderProjectPath) {
$locator = $this->composerJsonAndInstalledJsonSourceLocatorMaker->create($composerAutoloaderProjectPath);
Expand Down

0 comments on commit 3810804

Please sign in to comment.