Skip to content

Commit 7796af7

Browse files
authored
Merge pull request #108 from NiclasvanEyk/allow-phpparser-5
Allow php-parser 5.x
2 parents facb5e6 + f00dbbd commit 7796af7

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"php": "^7.1|^8.0",
2020
"doctrine/dbal": "~2.3|^3.3",
2121
"phpdocumentor/graphviz": "^1.0",
22-
"nikic/php-parser": "^2.0|^3.0|^4.0"
22+
"nikic/php-parser": "^2.0|^3.0|^4.0|^5.0"
2323
},
2424
"require-dev": {
2525
"larapack/dd": "^1.0",

src/ModelFinder.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ public function getModelsInDirectory(string $directory): Collection
5454

5555
protected function getFullyQualifiedClassNameFromFile(string $path): string
5656
{
57-
$parser = (new ParserFactory())->create(ParserFactory::PREFER_PHP7);
57+
$factory = new ParserFactory();
58+
$parser = method_exists($factory, 'createForHostVersion')
59+
? $factory->createForHostVersion()
60+
: $factory->create(ParserFactory::PREFER_PHP7);
5861

5962
$traverser = new NodeTraverser();
6063
$traverser->addVisitor(new NameResolver());

0 commit comments

Comments
 (0)