improve attribute print

This commit is contained in:
TomasVotruba 2020-05-05 22:32:46 +02:00
parent 7ae2145d14
commit 9e8150833b
12 changed files with 20 additions and 19 deletions

View File

@ -29,7 +29,7 @@ final class EntityTagValueNode extends AbstractDoctrineTagValueNode implements P
$content = $this->printPhpAttributeItems($items);
return $this->printAttributeContent($content);
return $this->printPhpAttributeContent($content);
}
private function createAttributeItems(): array

View File

@ -51,6 +51,6 @@ final class ColumnTagValueNode extends AbstractDoctrineTagValueNode implements P
$content = $this->printPhpAttributeItems($items);
return $this->printAttributeContent($content);
return $this->printPhpAttributeContent($content);
}
}

View File

@ -23,8 +23,10 @@ final class GeneratedValueTagValueNode extends AbstractDoctrineTagValueNode impl
public function toAttributeString(): string
{
// @todo add strategy
return $this->printAttributeContent();
$items = $this->filterOutMissingItems($this->items);
$content = $this->printPhpAttributeItems($items);
return $this->printPhpAttributeContent($content);
}
public function getSilentKey(): string

View File

@ -19,6 +19,6 @@ final class IdTagValueNode extends AbstractDoctrineTagValueNode implements PhpAt
public function toAttributeString(): string
{
return $this->printAttributeContent();
return $this->printPhpAttributeContent();
}
}

View File

@ -72,6 +72,6 @@ final class JoinColumnTagValueNode extends AbstractDoctrineTagValueNode implemen
$content = $this->printPhpAttributeItems($items);
return $this->printAttributeContent($content);
return $this->printPhpAttributeContent($content);
}
}

View File

@ -108,7 +108,7 @@ final class JoinTableTagValueNode extends AbstractDoctrineTagValueNode implement
$content = $this->printPhpAttributeItems($items);
$joinTableAttributeContent = $this->printAttributeContent($content);
$joinTableAttributeContent = $this->printPhpAttributeContent($content);
foreach ($this->joinColumns as $joinColumn) {
$joinTableAttributeContent .= PHP_EOL . $joinColumn->toAttributeString();

View File

@ -76,7 +76,7 @@ final class ManyToManyTagValueNode extends AbstractDoctrineTagValueNode implemen
$items = $this->filterOutMissingItems($items);
$content = $this->printPhpAttributeItems($items);
return $this->printAttributeContent($content);
return $this->printPhpAttributeContent($content);
}
private function createAttributeItems(): array

View File

@ -30,7 +30,7 @@ final class AssertEmailTagValueNode extends AbstractTagValueNode implements Type
$content = $this->printPhpAttributeItemsAsArray($items);
return $this->printAttributeContent($content);
return $this->printPhpAttributeContent($content);
}
public function getSilentKey(): string

View File

@ -26,6 +26,6 @@ final class AssertRangeTagValueNode extends AbstractTagValueNode implements Type
$content = $this->printPhpAttributeItemsAsArray($items);
return $this->printAttributeContent($content);
return $this->printPhpAttributeContent($content);
}
}

View File

@ -42,7 +42,6 @@ final class AnnotationToAttributeConverter
// 0. has 0 nodes, nothing to change
/** @var PhpAttributableTagNodeInterface[]&PhpDocTagValueNode[] $phpAttributableTagNodes */
$phpAttributableTagNodes = $phpDocInfo->findAllByType(PhpAttributableTagNodeInterface::class);
if ($phpAttributableTagNodes === []) {
return null;

View File

@ -6,12 +6,6 @@ namespace Rector\PhpAttribute\PhpDocNode;
trait PhpAttributePhpDocNodePrintTrait
{
public function printAttributeContent(string $content = ''): string
{
$attributeStart = '<<' . ltrim($this->getShortName(), '@');
return $attributeStart . $content . '>>';
}
/**
* @param string[] $items
*/
@ -24,10 +18,16 @@ trait PhpAttributePhpDocNodePrintTrait
return '(' . implode(', ', $items) . ')';
}
protected function printPhpAttributeContent(string $content = ''): string
{
$attributeStart = '<<' . ltrim($this->getShortName(), '@');
return $attributeStart . $content . '>>';
}
/**
* @param string[] $items
*/
public function printPhpAttributeItemsAsArray(array $items): string
protected function printPhpAttributeItemsAsArray(array $items): string
{
if ($items === []) {
return '';

View File

@ -24,7 +24,7 @@ use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
class StringServiceName extends KernelTestCase
{
/**
* @var some_value
* @var \some_value
*/
private $someValue;
protected function setUp()