From afcbdb08e6cc2a589a112722a34c6c17a9b757b8 Mon Sep 17 00:00:00 2001 From: bjorn Date: Fri, 31 Jan 2025 16:08:39 +0100 Subject: [PATCH] fix: enhance AnnotationToAttributeRector to handle Doctrine annotations because of changes in phpparser --- .../AnnotationToAttributeRector.php | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/Drupal10/Rector/Deprecation/AnnotationToAttributeRector.php b/src/Drupal10/Rector/Deprecation/AnnotationToAttributeRector.php index 3cbb9b23..7497fd53 100644 --- a/src/Drupal10/Rector/Deprecation/AnnotationToAttributeRector.php +++ b/src/Drupal10/Rector/Deprecation/AnnotationToAttributeRector.php @@ -189,17 +189,22 @@ protected function refactorWithConfiguration(Node $node, VersionedConfigurationI $docBlockHasChanged = \false; foreach ($tagsByName as $valueNode) { - if (!$valueNode->value instanceof GenericTagValueNode) { + if (!$valueNode->value instanceof GenericTagValueNode && !$valueNode->value instanceof DoctrineAnnotationTagValueNode) { continue; } if ($hasAttribute === false) { - $stringValue = $valueNode->value->value; - $stringValue = '{'.trim($stringValue, '()').'}'; - $tokenIterator = $this->tokenIteratorFactory->create($stringValue); - $data = $this->arrayParser->parseCurlyArray($tokenIterator, $node); - $attribute = $this->createAttribute($configuration->getAttributeClass(), $data); - $node->attrGroups[] = new AttributeGroup([$attribute]); + if ($valueNode->value instanceof GenericTagValueNode) { + $stringValue = $valueNode->value->value; + $stringValue = '{'.trim($stringValue, '()').'}'; + $tokenIterator = $this->tokenIteratorFactory->create($stringValue); + $data = $this->arrayParser->parseCurlyArray($tokenIterator, $node); + $attribute = $this->createAttribute($configuration->getAttributeClass(), $data); + $node->attrGroups[] = new AttributeGroup([$attribute]); + } elseif ($valueNode->value instanceof DoctrineAnnotationTagValueNode) { + $attribute = $this->createAttribute($configuration->getAttributeClass(), $valueNode->value->values); + $node->attrGroups[] = new AttributeGroup([$attribute]); + } } if (version_compare($this->installedDrupalVersion(), $configuration->getRemoveVersion(), '>=')) {