Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2030c26

Browse files
committed
[Translation] Fix extraction when dealing with VariadicPlaceholder parameters
1 parent 3444c1e commit 2030c26

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

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

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,32 +42,31 @@ protected function addMessageToCatalogue(string $message, ?string $domain, int $
4242

4343
protected function getStringArguments(Node\Expr\CallLike|Node\Attribute|Node\Expr\New_ $node, int|string $index, bool $indexIsRegex = false): array
4444
{
45-
$args = $node instanceof Node\Expr\CallLike ? $node->getArgs() : $node->args;
46-
4745
if (\is_string($index)) {
4846
return $this->getStringNamedArguments($node, $index, $indexIsRegex);
4947
}
5048

49+
$args = $node instanceof Node\Expr\CallLike ? $node->getRawArgs() : $node->args;
50+
5151
if (\count($args) < $index) {
5252
return [];
5353
}
5454

55-
/** @var Node\Arg $arg */
56-
$arg = $args[$index];
57-
if (!$result = $this->getStringValue($arg->value)) {
58-
return [];
55+
if (($arg = $args[$index]) instanceof Node\Arg) {
56+
if ($result = $this->getStringValue($arg->value)) {
57+
return [$result];
58+
}
5959
}
6060

61-
return [$result];
61+
return [];
6262
}
6363

6464
protected function hasNodeNamedArguments(Node\Expr\CallLike|Node\Attribute|Node\Expr\New_ $node): bool
6565
{
66-
$args = $node instanceof Node\Expr\CallLike ? $node->getArgs() : $node->args;
66+
$args = $node instanceof Node\Expr\CallLike ? $node->getRawArgs() : $node->args;
6767

68-
/** @var Node\Arg $arg */
6968
foreach ($args as $arg) {
70-
if (null !== $arg->name) {
69+
if ($arg instanceof Node\Arg && null !== $arg->name) {
7170
return true;
7271
}
7372
}

0 commit comments

Comments
 (0)