mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-26 20:53:31 +00:00
improve attribute print
This commit is contained in:
parent
7ae2145d14
commit
9e8150833b
|
@ -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
|
||||
|
|
|
@ -51,6 +51,6 @@ final class ColumnTagValueNode extends AbstractDoctrineTagValueNode implements P
|
|||
|
||||
$content = $this->printPhpAttributeItems($items);
|
||||
|
||||
return $this->printAttributeContent($content);
|
||||
return $this->printPhpAttributeContent($content);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -19,6 +19,6 @@ final class IdTagValueNode extends AbstractDoctrineTagValueNode implements PhpAt
|
|||
|
||||
public function toAttributeString(): string
|
||||
{
|
||||
return $this->printAttributeContent();
|
||||
return $this->printPhpAttributeContent();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,6 +72,6 @@ final class JoinColumnTagValueNode extends AbstractDoctrineTagValueNode implemen
|
|||
|
||||
$content = $this->printPhpAttributeItems($items);
|
||||
|
||||
return $this->printAttributeContent($content);
|
||||
return $this->printPhpAttributeContent($content);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -26,6 +26,6 @@ final class AssertRangeTagValueNode extends AbstractTagValueNode implements Type
|
|||
|
||||
$content = $this->printPhpAttributeItemsAsArray($items);
|
||||
|
||||
return $this->printAttributeContent($content);
|
||||
return $this->printPhpAttributeContent($content);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 '';
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue
Block a user