betterStandardPrinter = $betterStandardPrinter; } public function createFromAttribute(\PhpParser\Node\Attribute $attribute, string $className) : \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode { $items = $this->createItemsFromArgs($attribute->args); return new \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode($className, null, $items); } /** * @param Arg[] $args * @return mixed[] */ private function createItemsFromArgs(array $args) : array { $items = []; foreach ($args as $arg) { if ($arg->value instanceof \PhpParser\Node\Scalar\String_) { // standardize double quotes for annotations $arg->value->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::KIND, \PhpParser\Node\Scalar\String_::KIND_DOUBLE_QUOTED); } $itemValue = $this->betterStandardPrinter->print($arg->value); if ($arg->name !== null) { $name = $this->betterStandardPrinter->print($arg->name); $items[$name] = $itemValue; } else { $items[] = $itemValue; } } return $items; } }