Skip to content

Commit

Permalink
StubSourceLocatorFactory - always use PHP 8 parser for PhpStorm stubs
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Sep 12, 2021
1 parent 109bf99 commit 731ce1d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion conf/config.stubValidator.neon
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ services:
-
class: PHPStan\PhpDoc\StubSourceLocatorFactory
arguments:
parser: @phpParserDecorator
php8Parser: @php8PhpParser
stubFiles: %stubFiles%

nodeScopeResolverClassReflector:
Expand Down
10 changes: 5 additions & 5 deletions src/PhpDoc/StubSourceLocatorFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
class StubSourceLocatorFactory
{

private \PhpParser\Parser $parser;
private \PhpParser\Parser $php8Parser;

private PhpStormStubsSourceStubber $phpStormStubsSourceStubber;

Expand All @@ -30,14 +30,14 @@ class StubSourceLocatorFactory
* @param string[] $stubFiles
*/
public function __construct(
\PhpParser\Parser $parser,
\PhpParser\Parser $php8Parser,
PhpStormStubsSourceStubber $phpStormStubsSourceStubber,
OptimizedSingleFileSourceLocatorRepository $optimizedSingleFileSourceLocatorRepository,
Container $container,
array $stubFiles
)
{
$this->parser = $parser;
$this->php8Parser = $php8Parser;
$this->phpStormStubsSourceStubber = $phpStormStubsSourceStubber;
$this->optimizedSingleFileSourceLocatorRepository = $optimizedSingleFileSourceLocatorRepository;
$this->container = $container;
Expand All @@ -47,14 +47,14 @@ public function __construct(
public function create(): SourceLocator
{
$locators = [];
$astLocator = new Locator($this->parser, function (): FunctionReflector {
$astPhp8Locator = new Locator($this->php8Parser, function (): FunctionReflector {
return $this->container->getService('stubFunctionReflector');
});
foreach ($this->stubFiles as $stubFile) {
$locators[] = $this->optimizedSingleFileSourceLocatorRepository->getOrCreate($stubFile);
}

$locators[] = new PhpInternalSourceLocator($astLocator, $this->phpStormStubsSourceStubber);
$locators[] = new PhpInternalSourceLocator($astPhp8Locator, $this->phpStormStubsSourceStubber);

return new MemoizingSourceLocator(new AggregateSourceLocator($locators));
}
Expand Down

0 comments on commit 731ce1d

Please sign in to comment.