Skip to content

Commit

Permalink
Add support for nikic/php-parser:^5
Browse files Browse the repository at this point in the history
- `createForHostVersion` has been added to php-parse 4.18 so code can
  run with both versions [1]
- therefore also bumped the minimum required version to it

Note:
The dev dependency vimeo/psalm is **not** compatible with
php-parser:^5 currently. This does not impact usages of this library,
but sometimes cause friction when working on this library.
For our CI this isn't a problem, because we already remove that
dependency before running the test suite.

[1] https://github.com/nikic/PHP-Parser/blob/master/UPGRADE-5.0.md#changes-to-the-parser-factory
  • Loading branch information
mfn committed Jan 27, 2024
1 parent 4dc20b0 commit 8c5d76e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"illuminate/console": "^8 || ^9 || ^10",
"illuminate/filesystem": "^8 || ^9 || ^10",
"illuminate/support": "^8 || ^9 || ^10",
"nikic/php-parser": "^4.7",
"nikic/php-parser": "^4.18|^5",
"phpdocumentor/type-resolver": "^1.1.0"
},
"require-dev": {
Expand Down
2 changes: 1 addition & 1 deletion src/UsesResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function loadFromCode(string $classFQN, string $code): array
'\\'
);

$parser = (new ParserFactory())->create(ParserFactory::PREFER_PHP7);
$parser = (new ParserFactory())->createForHostVersion();
$namespaceData = null;

foreach ($parser->parse($code) as $node) {
Expand Down

0 comments on commit 8c5d76e

Please sign in to comment.