8000 add support for nikic/php-parser 5.0 · symfony/symfony@1627f6b · GitHub
[go: up one dir, main page]

Skip to content

Commit 1627f6b

Browse files
committed
add support for nikic/php-parser 5.0
1 parent 1c6fcf4 commit 1627f6b

File tree

6 files changed

+13
-4
lines changed

6 files changed

+13
-4
lines changed

.github/workflows/unit-tests.yml

+4
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,10 @@ jobs:
128128
echo SYMFONY_REQUIRE=">=$([ '${{ matrix.mode }}' = low-deps ] && echo 4.4 || echo $SYMFONY_VERSION)" >> $GITHUB_ENV
129129
[[ "${{ matrix.mode }}" = *-deps ]] && mv composer.json.phpunit composer.json || true
130130
131+
if [[ "${{ matrix.mode }}" = low-deps ]]; then
132+
echo SYMFONY_PHPUNIT_REQUIRE="nikic/php-parser:^4.16" >> $GITHUB_ENV
133+
fi
134+
131135
- name: Install dependencies
132136
run: |
133137
echo "::group::composer update"

composer.json

+1
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@
140140
"league/uri": "^6.5|^7.0",
141141
"masterminds/html5": "^2.7.2",
142142
"monolog/monolog": "^1.25.1|^2",
143+
"nikic/php-parser": "^4.16|^5.0",
143144
"nyholm/psr7": "^1.0",
144145
"pda/pheanstalk": "^4.0",
145146
"php-http/discovery": "^1.15",

src/Symfony/Component/Translation/Extractor/PhpAstExtractor.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,11 @@ public function __construct(
3939
throw new \LogicException(sprintf('You cannot use "%s" as the "nikic/php-parser" package is not installed. Try running "composer require nikic/php-parser".', static::class));
4040
}
4141

42-
$this->parser = (new ParserFactory())->create(ParserFactory::PREFER_PHP7);
42+
if (method_exists(ParserFactory::class, 'createForHostVersion')) {
43+
$this->parser = (new ParserFactory())->createForHostVersion();
44+
} else {
45+
$this->parser = (new ParserFactory())->create(ParserFactory::PREFER_PHP7);
46+
}
4347
}
4448

4549
public function extract(iterable|string $resource, MessageCatalogue $catalogue): void

src/Symfony/Component/Translation/Extractor/Visitor/ConstraintVisitor.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function enterNode(Node $node): ?Node
4242
return null;
4343
}
4444

45-
$parts = $className->parts;
45+
$parts = $className->getParts();
4646
$isConstraintClass = false;
4747

4848
foreach ($parts as $part) {

src/Symfony/Component/Translation/Extractor/Visitor/TranslatableMessageVisitor.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function enterNode(Node $node): ?Node
3434
return null;
3535
}
3636

37-
if (!\in_array('TranslatableMessage', $className->parts, true)) {
37+
if (!\in_array('TranslatableMessage', $className->getParts(), true)) {
3838
return null;
3939
}
4040

src/Symfony/Component/Translation/composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"symfony/translation-contracts": "^2.5|^3.0"
2323
},
2424
"require-dev": {
25-
"nikic/php-parser": "^4.13",
25+
"nikic/php-parser": "^4.16|^5.0",
2626
"symfony/config": "^5.4|^6.0",
2727
"symfony/console": "^5.4|^6.0",
2828
"symfony/dependency-injection": "^5.4|^6.0",

0 commit comments

Comments
 (0)
0