Skip to content

Commit 731ce1d

Browse files
committed
StubSourceLocatorFactory - always use PHP 8 parser for PhpStorm stubs
1 parent 109bf99 commit 731ce1d

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

conf/config.stubValidator.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ services:
1010
-
1111
class: PHPStan\PhpDoc\StubSourceLocatorFactory
1212
arguments:
13-
parser: @phpParserDecorator
13+
php8Parser: @php8PhpParser
1414
stubFiles: %stubFiles%
1515

1616
nodeScopeResolverClassReflector:

src/PhpDoc/StubSourceLocatorFactory.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
class StubSourceLocatorFactory
1616
{
1717

18-
private \PhpParser\Parser $parser;
18+
private \PhpParser\Parser $php8Parser;
1919

2020
private PhpStormStubsSourceStubber $phpStormStubsSourceStubber;
2121

@@ -30,14 +30,14 @@ class StubSourceLocatorFactory
3030
* @param string[] $stubFiles
3131
*/
3232
public function __construct(
33-
\PhpParser\Parser $parser,
33+
\PhpParser\Parser $php8Parser,
3434
PhpStormStubsSourceStubber $phpStormStubsSourceStubber,
3535
OptimizedSingleFileSourceLocatorRepository $optimizedSingleFileSourceLocatorRepository,
3636
Container $container,
3737
array $stubFiles
3838
)
3939
{
40-
$this->parser = $parser;
40+
$this->php8Parser = $php8Parser;
4141
$this->phpStormStubsSourceStubber = $phpStormStubsSourceStubber;
4242
$this->optimizedSingleFileSourceLocatorRepository = $optimizedSingleFileSourceLocatorRepository;
4343
$this->container = $container;
@@ -47,14 +47,14 @@ public function __construct(
4747
public function create(): SourceLocator
4848
{
4949
$locators = [];
50-
$astLocator = new Locator($this->parser, function (): FunctionReflector {
50+
$astPhp8Locator = new Locator($this->php8Parser, function (): FunctionReflector {
5151
return $this->container->getService('stubFunctionReflector');
5252
});
5353
foreach ($this->stubFiles as $stubFile) {
5454
$locators[] = $this->optimizedSingleFileSourceLocatorRepository->getOrCreate($stubFile);
5555
}
5656

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

5959
return new MemoizingSourceLocator(new AggregateSourceLocator($locators));
6060
}

0 commit comments

Comments
 (0)