Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php declare(strict_types=1);

namespace Rector\BetterPhpDocParser\Attributes\Ast\PhpDoc;

use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode;
use Rector\BetterPhpDocParser\Attributes\Attribute\AttributeTrait;
use Rector\BetterPhpDocParser\Attributes\Contract\Ast\AttributeAwareNodeInterface;

/**
* Useful for annotation class based annotation, e.g. @ORM\Entity to prevent space
* between the @ORM\Entity and (someContent)
*/
final class SpacelessPhpDocTagNode extends PhpDocTagNode implements AttributeAwareNodeInterface
{
use AttributeTrait;

public function __toString(): string
{
return $this->name . $this->value;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode;
use PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode;
use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode;
use Rector\BetterPhpDocParser\Attributes\Ast\PhpDoc\AttributeAwarePhpDocTagNode;
use Rector\BetterPhpDocParser\Attributes\Ast\PhpDoc\SpacelessPhpDocTagNode;
use Rector\Doctrine\Uuid\JoinTableNameResolver;
use Rector\Doctrine\ValueObject\DoctrineClass;
use Rector\DoctrinePhpDocParser\Ast\PhpDoc\Property_\ColumnTagValueNode;
Expand Down Expand Up @@ -44,7 +44,7 @@ public function createVarTagUuidInterface(): PhpDocTagNode

public function createIdTag(): PhpDocTagNode
{
return new PhpDocTagNode(IdTagValueNode::SHORT_NAME, new IdTagValueNode());
return new SpacelessPhpDocTagNode(IdTagValueNode::SHORT_NAME, new IdTagValueNode());
}

public function createUuidColumnTag(bool $isNullable): PhpDocTagNode
Expand All @@ -59,17 +59,19 @@ public function createUuidColumnTag(bool $isNullable): PhpDocTagNode
$isNullable ? true : null
);

return new PhpDocTagNode($columnTagValueNode::SHORT_NAME, $columnTagValueNode);
return new SpacelessPhpDocTagNode($columnTagValueNode::SHORT_NAME, $columnTagValueNode);
}

public function createGeneratedValueTag(): PhpDocTagNode
{
return new PhpDocTagNode(GeneratedValueTagValueNode::SHORT_NAME, new GeneratedValueTagValueNode('CUSTOM'));
return new SpacelessPhpDocTagNode(GeneratedValueTagValueNode::SHORT_NAME, new GeneratedValueTagValueNode(
'CUSTOM'
));
}

public function createCustomIdGeneratorTag(): PhpDocTagNode
{
return new PhpDocTagNode(
return new SpacelessPhpDocTagNode(
CustomIdGeneratorTagValueNode::SHORT_NAME,
new CustomIdGeneratorTagValueNode($this->doctrineUuidGeneratorClass)
);
Expand All @@ -86,13 +88,13 @@ public function createJoinTableTagNode(Property $property): PhpDocTagNode
[new JoinColumnTagValueNode(null, 'uuid')]
);

return new AttributeAwarePhpDocTagNode(JoinTableTagValueNode::SHORT_NAME, $joinTableTagValueNode);
return new SpacelessPhpDocTagNode(JoinTableTagValueNode::SHORT_NAME, $joinTableTagValueNode);
}

public function createJoinColumnTagNode(): PhpDocTagNode
{
$joinColumnTagValueNode = new JoinColumnTagValueNode(null, 'uuid', null, false);

return new AttributeAwarePhpDocTagNode(JoinColumnTagValueNode::SHORT_NAME, $joinColumnTagValueNode);
return new SpacelessPhpDocTagNode(JoinColumnTagValueNode::SHORT_NAME, $joinColumnTagValueNode);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class ToMany
private $amenity;
/**
* @ORM\ManyToMany(targetEntity="Rector\Doctrine\Tests\Rector\Class_\AddUuidMirrorForRelationPropertyRector\Fixture\FooEntity", cascade={"persist", "merge"})
* @ORM\JoinTable (name="tomany_fooentity_uuid", joinColumns={@ORM\JoinColumn(referencedColumnName="uuid")}, inverseJoinColumns={@ORM\JoinColumn(referencedColumnName="uuid")})
* @ORM\JoinTable(name="tomany_fooentity_uuid", joinColumns={@ORM\JoinColumn(referencedColumnName="uuid")}, inverseJoinColumns={@ORM\JoinColumn(referencedColumnName="uuid")})
*/
private $amenityUuid;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ abstract class ParentSingleTableInheritanceWithIdentifier
}
/**
* @var \Ramsey\Uuid\UuidInterface
* @ORM\Column (type="uuid_binary", unique=true, nullable=true)
* @ORM\Column(type="uuid_binary", unique=true, nullable=true)
*/
private $uuid;
/**
Expand Down