-
Notifications
You must be signed in to change notification settings - Fork 478
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
afc5092
commit 0f8a61a
Showing
2 changed files
with
63 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace PHPStan\Parser; | ||
|
||
use PHPStan\File\FileHelper; | ||
|
||
class PathRoutingParser implements Parser | ||
{ | ||
|
||
private FileHelper $fileHelper; | ||
|
||
private Parser $currentPhpVersionRichParser; | ||
|
||
private Parser $currentPhpVersionSimpleParser; | ||
|
||
private Parser $php8Parser; | ||
|
||
public function __construct( | ||
FileHelper $fileHelper, | ||
Parser $currentPhpVersionRichParser, | ||
Parser $currentPhpVersionSimpleParser, | ||
Parser $php8Parser | ||
) | ||
{ | ||
$this->fileHelper = $fileHelper; | ||
$this->currentPhpVersionRichParser = $currentPhpVersionRichParser; | ||
$this->currentPhpVersionSimpleParser = $currentPhpVersionSimpleParser; | ||
$this->php8Parser = $php8Parser; | ||
} | ||
|
||
public function parseFile(string $file): array | ||
{ | ||
$file = $this->fileHelper->normalizePath($file, '/'); | ||
if (strpos($file, 'vendor/jetbrains/phpstorm-stubs') !== false) { | ||
return $this->php8Parser->parseFile($file); | ||
} | ||
|
||
return $this->currentPhpVersionRichParser->parseFile($file); | ||
} | ||
|
||
public function parseString(string $sourceCode): array | ||
{ | ||
return $this->currentPhpVersionRichParser->parseString($sourceCode); | ||
} | ||
|
||
} |