rector/vendor/rector/rector-doctrine/rules/CodeQuality/AttributeTransformer/PropertyAttributeTransformer/IdColumnAttributeTransformer.php
Tomas Votruba 53742c371b Updated Rector to commit 70fa502a59dfb8f81011a46a456e1ccb4051be76
70fa502a59 [CodeQuality] Skip private static call from static:: on LocallyCalledStaticMethodToNonStaticRector (#5620)
2024-02-15 09:08:32 +00:00

31 lines
1.1 KiB
PHP

<?php
declare (strict_types=1);
namespace Rector\Doctrine\CodeQuality\AttributeTransformer\PropertyAttributeTransformer;
use PhpParser\Node\Stmt\Property;
use Rector\Doctrine\CodeQuality\Contract\PropertyAttributeTransformerInterface;
use Rector\Doctrine\CodeQuality\NodeFactory\AttributeFactory;
use Rector\Doctrine\CodeQuality\ValueObject\EntityMapping;
use Rector\Doctrine\Enum\MappingClass;
final class IdColumnAttributeTransformer implements PropertyAttributeTransformerInterface
{
public function transform(EntityMapping $entityMapping, Property $property) : void
{
$idMapping = $entityMapping->matchIdPropertyMapping($property);
if (!\is_array($idMapping)) {
return;
}
$args = [];
$type = $idMapping['type'] ?? null;
if ($type) {
$args[] = AttributeFactory::createNamedArg($type, 'type');
}
$property->attrGroups[] = AttributeFactory::createGroup($this->getClassName(), $args);
}
public function getClassName() : string
{
return MappingClass::COLUMN;
}
}