From 41dba775f929ac567e7b4c601a83e7432c6f2051 Mon Sep 17 00:00:00 2001 From: Tony Lea Date: Thu, 9 May 2024 17:24:19 -0400 Subject: [PATCH] trying to update the correct function --- composer.json | 2 +- src/ArrayFile.php | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index 0935430..ea0d45e 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ ], "require": { "php": "^7.4.0 || ^8.0", - "nikic/php-parser": "^4.10" + "nikic/php-parser": "^5.0" }, "require-dev": { "phpstan/phpstan": "^1.6", diff --git a/src/ArrayFile.php b/src/ArrayFile.php index 110e382..cd07887 100644 --- a/src/ArrayFile.php +++ b/src/ArrayFile.php @@ -79,15 +79,20 @@ public static function open(string $filePath, bool $throwIfMissing = false) throw new \InvalidArgumentException('file not found'); } - $lexer = new Lexer\Emulative([ + // Configure the Lexer options, including usedAttributes + $lexerOptions = [ 'usedAttributes' => [ 'comments', 'startTokenPos', 'startLine', 'endTokenPos', - 'endLine' - ] - ]); + 'endLine', + ], + ]; + + // Instantiate the Lexer with default PHP version (null) and lexer options + $lexer = new Lexer\Emulative(null, $lexerOptions); + $parser = (new ParserFactory)->create(ParserFactory::PREFER_PHP7, $lexer); try { @@ -96,7 +101,7 @@ public static function open(string $filePath, bool $throwIfMissing = false) ? file_get_contents($filePath) : sprintf('