-
Notifications
You must be signed in to change notification settings - Fork 457
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use non-emulative Lexer if the desired PHP version matches the runtim…
…e one
- Loading branch information
1 parent
c1e8f6f
commit 9f53ac5
Showing
3 changed files
with
35 additions
and
1 deletion.
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,27 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace PHPStan\Parser; | ||
|
||
use PhpParser\Lexer; | ||
use PHPStan\Php\PhpVersion; | ||
|
||
class LexerFactory | ||
{ | ||
|
||
private PhpVersion $phpVersion; | ||
|
||
public function __construct(PhpVersion $phpVersion) | ||
{ | ||
$this->phpVersion = $phpVersion; | ||
} | ||
|
||
public function create(): Lexer | ||
{ | ||
if ($this->phpVersion->getVersionId() === PHP_VERSION_ID) { | ||
return new Lexer(); | ||
} | ||
|
||
return new Lexer\Emulative(); | ||
} | ||
|
||
} |
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