Skip to content

Commit 706470b

Browse files
GCthMarcin Jakubowski
andauthored
#188 use host PHP version instead of hardcoded version to parse newer syntax (#189)
Co-authored-by: Marcin Jakubowski <marcin.jakubowski@dsnet.pl>
1 parent 8b219cf commit 706470b

2 files changed

Lines changed: 2 additions & 5 deletions

File tree

src/FileExtractor/PHPFileExtractor.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
use PhpParser\NodeTraverser;
1616
use PhpParser\NodeVisitor;
1717
use PhpParser\ParserFactory;
18-
use PhpParser\PhpVersion;
1918
use Symfony\Component\Finder\SplFileInfo;
2019
use Translation\Extractor\Model\SourceCollection;
2120
use Translation\Extractor\Visitor\Visitor;
@@ -33,8 +32,7 @@ final class PHPFileExtractor implements FileExtractor
3332
public function getSourceLocations(SplFileInfo $file, SourceCollection $collection): void
3433
{
3534
$path = $file->getRelativePath();
36-
/** @phpstan-ignore-next-line */
37-
$parser = (new ParserFactory())->createForVersion(PhpVersion::fromString('8.1'));
35+
$parser = (new ParserFactory())->createForHostVersion();
3836
$traverser = new NodeTraverser();
3937
$traverser->addVisitor(new NodeVisitor\NameResolver());
4038
foreach ($this->visitors as $v) {

src/Visitor/Php/Symfony/FormTrait.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
use PhpParser\NodeTraverser;
1717
use PhpParser\NodeVisitor\NameResolver;
1818
use PhpParser\ParserFactory;
19-
use PhpParser\PhpVersion;
2019

2120
trait FormTrait
2221
{
@@ -80,7 +79,7 @@ protected function loadParentInterfaces(string $parentFqcn): array
8079
}
8180

8281
/** @phpstan-ignore-next-line */
83-
$parser = (new ParserFactory())->createForVersion(PhpVersion::fromString('8.1'));
82+
$parser = (new ParserFactory())->createForHostVersion();
8483
$code = file_get_contents($filePath);
8584
$stmts = $parser->parse($code);
8685

0 commit comments

Comments
 (0)