Skip to content

Commit

Permalink
trying to update the correct function
Browse files Browse the repository at this point in the history
  • Loading branch information
tnylea authored May 9, 2024
1 parent b8ab7d3 commit 41dba77
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
15 changes: 10 additions & 5 deletions src/ArrayFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -96,7 +101,7 @@ public static function open(string $filePath, bool $throwIfMissing = false)
? file_get_contents($filePath)
: sprintf('<?php%1$s%1$sreturn [];%1$s', "\n")
);
} catch (Error $e) {
} catch (\PhpParser\Error $e) {
throw new ConfigWriterException($e);
}

Expand Down

0 comments on commit 41dba77

Please sign in to comment.