File tree 2 files changed +63
-3
lines changed
2 files changed +63
-3
lines changed Original file line number Diff line number Diff line change @@ -519,7 +519,7 @@ services:
519
519
-
520
520
class : PHPStan\Parser\CachedParser
521
521
arguments :
522
- originalParser : @currentPhpVersionRichParser
522
+ originalParser : @pathRoutingParser
523
523
cachedNodesByStringCountMax : %cache.nodesByStringCountMax%
524
524
525
525
-
@@ -1302,7 +1302,7 @@ services:
1302
1302
-
1303
1303
class : Roave\BetterReflection\SourceLocator\SourceStubber\PhpStormStubsSourceStubber
1304
1304
arguments :
1305
- phpParser : @php8Parser
1305
+ phpParser : @php8PhpParser
1306
1306
phpVersionId : %phpVersion%
1307
1307
autowired :
1308
1308
- Roave\BetterReflection\SourceLocator\SourceStubber\PhpStormStubsSourceStubber
@@ -1316,12 +1316,26 @@ services:
1316
1316
class : PhpParser\Lexer\Emulative
1317
1317
autowired : false
1318
1318
1319
- php8Parser :
1319
+ php8PhpParser :
1320
1320
class : PhpParser\Parser\Php7
1321
1321
arguments :
1322
1322
lexer : @php8Lexer
1323
1323
autowired : false
1324
1324
1325
+ php8Parser :
1326
+ class : PHPStan\Parser\SimpleParser
1327
+ arguments :
1328
+ parser : @php8PhpParser
1329
+ autowired : false
1330
+
1331
+ pathRoutingParser :
1332
+ class : PHPStan\Parser\PathRoutingParser
1333
+ arguments :
1334
+ currentPhpVersionRichParser : @currentPhpVersionRichParser
1335
+ currentPhpVersionSimpleParser : @currentPhpVersionSimpleParser
1336
+ php8Parser : @php8Parser
1337
+ autowired : false
1338
+
1325
1339
# Error formatters
1326
1340
1327
1341
errorFormatter.raw :
Original file line number Diff line number Diff line change
1
+ <?php declare (strict_types = 1 );
2
+
3
+ namespace PHPStan \Parser ;
4
+
5
+ use PHPStan \File \FileHelper ;
6
+
7
+ class PathRoutingParser implements Parser
8
+ {
9
+
10
+ private FileHelper $ fileHelper ;
11
+
12
+ private Parser $ currentPhpVersionRichParser ;
13
+
14
+ private Parser $ currentPhpVersionSimpleParser ;
15
+
16
+ private Parser $ php8Parser ;
17
+
18
+ public function __construct (
19
+ FileHelper $ fileHelper ,
20
+ Parser $ currentPhpVersionRichParser ,
21
+ Parser $ currentPhpVersionSimpleParser ,
22
+ Parser $ php8Parser
23
+ )
24
+ {
25
+ $ this ->fileHelper = $ fileHelper ;
26
+ $ this ->currentPhpVersionRichParser = $ currentPhpVersionRichParser ;
27
+ $ this ->currentPhpVersionSimpleParser = $ currentPhpVersionSimpleParser ;
28
+ $ this ->php8Parser = $ php8Parser ;
29
+ }
30
+
31
+ public function parseFile (string $ file ): array
32
+ {
33
+ $ file = $ this ->fileHelper ->normalizePath ($ file , '/ ' );
34
+ if (strpos ($ file , 'vendor/jetbrains/phpstorm-stubs ' ) !== false ) {
35
+ return $ this ->php8Parser ->parseFile ($ file );
36
+ }
37
+
38
+ return $ this ->currentPhpVersionRichParser ->parseFile ($ file );
39
+ }
40
+
41
+ public function parseString (string $ sourceCode ): array
42
+ {
43
+ return $ this ->currentPhpVersionRichParser ->parseString ($ sourceCode );
44
+ }
45
+
46
+ }
You can’t perform that action at this time.
0 commit comments