Skip to content

Commit

Permalink
Fix convertTranslateAnnotation early return. Also simplify a little b…
Browse files Browse the repository at this point in the history
…y taking the actual annotation instead of its container.
  • Loading branch information
bbrala committed Mar 8, 2024
1 parent 6dad267 commit 651332f
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ private function createAttribute(array $parsedArgs): Attribute
$args = [];
foreach ($parsedArgs as $value) {
if ($value->key === 'action_label') {
$arg = $this->convertTranslateAnnotation($value);
$arg = $this->convertTranslateAnnotation($value->value);
} else {
$arg = new String_($value->value->value);
}
Expand All @@ -226,10 +226,10 @@ private function createAttribute(array $parsedArgs): Attribute
return new Attribute($fullyQualified, $args);
}

public function convertTranslateAnnotation(ArrayItemNode $value): ?Node\Expr\New_
public function convertTranslateAnnotation(DoctrineAnnotationTagValueNode $value): ?Node\Expr\New_
{
// Check the annotation type, this will be helpful later.
if (!$value->value instanceof DoctrineAnnotationTagValueNode || $value->value->identifierTypeNode->name === 'Translation') {
if ($value->identifierTypeNode->name !== '@Translation') {
return null;
}

Expand All @@ -238,7 +238,7 @@ public function convertTranslateAnnotation(ArrayItemNode $value): ?Node\Expr\New
$contextArg = null;

// Loop through the values of the annotation, just to make 100% sure we have the correct argument order
foreach ($value->value->values as $translateValue) {
foreach ($value->values as $translateValue) {
if ($translateValue->key === null) {
$valueArg = $this->nodeFactory->createArg($translateValue->value->value);
}
Expand Down

0 comments on commit 651332f

Please sign in to comment.