Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentLanglet committed Jul 3, 2024
1 parent d1f3c76 commit 9893a40
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions src/Psalm/Internal/Provider/StatementsProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use PhpParser\Lexer\Emulative;
use PhpParser\Node\Stmt;
use PhpParser\Parser;
use PhpParser\PhpVersion;
use Psalm\CodeLocation\ParseErrorLocation;
use Psalm\Codebase;
use Psalm\Config;
Expand Down Expand Up @@ -390,21 +391,14 @@ public static function parseStatements(
?array $existing_statements = null,
?array $file_changes = null
): array {
$attributes = [
'comments', 'startLine', 'startFilePos', 'endFilePos',
];

if (!self::$lexer) {
$major_version = Codebase::transformPhpVersionId($analysis_php_version_id, 10_000);
$minor_version = Codebase::transformPhpVersionId($analysis_php_version_id % 10_000, 100);
self::$lexer = new Emulative([
'usedAttributes' => $attributes,
'phpVersion' => $major_version . '.' . $minor_version,
]);
self::$lexer = new Emulative(PhpVersion::fromComponents($major_version, $minor_version));
}

if (!self::$parser) {
self::$parser = (new PhpParser\ParserFactory())->create(PhpParser\ParserFactory::ONLY_PHP7, self::$lexer);
self::$parser = new Parser\Php7(self::$lexer);
}

$used_cached_statements = false;
Expand Down

0 comments on commit 9893a40

Please sign in to comment.