Skip to content

Commit 59b27cf

Browse files
committed
fix: AttributeValueResolver should not drop values of annotations
If the file being parsed has already imported a class matching the name of the annotation tag, then the annotation tag will have been parsed as a DoctrineAnnotationTagValueNode. For some tags - e.g. Behat steps - the `$phpDocTagNode->value` will cast to an empty string (because the annotation text does not actually contain valid Doctrine annotation values). In this case, the actual annotation value needs to be retrieved from `$phpDocTagNode->value->getOriginalContent()`. This was causing AnnotationToAttributeRector to drop the attribute values when converting from annotations to attributes in a file that already contained some attributes. This was previously implemented, but was reverted more recently as part of dropping support for comments on these nodes.
1 parent 7366fc5 commit 59b27cf

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

rules/Php80/Rector/Class_/AttributeValueResolver.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ public function resolve(
3232
if ($phpDocTagNode->value instanceof DoctrineAnnotationTagValueNode) {
3333
$originalContent = (string) $phpDocTagNode->value->getOriginalContent();
3434

35-
if ($docValue !== '') {
35+
if ($docValue === '') {
36+
$docValue = $originalContent;
37+
} else {
3638
$attributeComment = ltrim($originalContent, $docValue);
3739
if ($attributeComment !== '') {
3840
$docValue .= "\n" . $attributeComment;

0 commit comments

Comments
 (0)