mirror of
https://github.com/rectorphp/rector.git
synced 2024-05-31 16:30:51 +00:00
53742c371b
70fa502a59
[CodeQuality] Skip private static call from static:: on LocallyCalledStaticMethodToNonStaticRector (#5620)
41 lines
1.5 KiB
PHP
41 lines
1.5 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\Helper\NodeValueNormalizer;
|
|
use Rector\Doctrine\CodeQuality\NodeFactory\AttributeFactory;
|
|
use Rector\Doctrine\CodeQuality\ValueObject\EntityMapping;
|
|
use Rector\Doctrine\Enum\MappingClass;
|
|
use Rector\PhpParser\Node\NodeFactory;
|
|
final class EmbeddedPropertyAttributeTransformer implements PropertyAttributeTransformerInterface
|
|
{
|
|
/**
|
|
* @readonly
|
|
* @var \Rector\PhpParser\Node\NodeFactory
|
|
*/
|
|
private $nodeFactory;
|
|
public function __construct(NodeFactory $nodeFactory)
|
|
{
|
|
$this->nodeFactory = $nodeFactory;
|
|
}
|
|
public function transform(EntityMapping $entityMapping, Property $property) : void
|
|
{
|
|
$propertyMapping = $entityMapping->matchEmbeddedPropertyMapping($property);
|
|
if ($propertyMapping === null) {
|
|
return;
|
|
}
|
|
// handled in another attribute
|
|
unset($propertyMapping['nullable']);
|
|
$args = $this->nodeFactory->createArgs($propertyMapping);
|
|
$property->attrGroups[] = AttributeFactory::createGroup($this->getClassName(), $args);
|
|
NodeValueNormalizer::ensureKeyIsClassConstFetch($args, 'class');
|
|
}
|
|
public function getClassName() : string
|
|
{
|
|
return MappingClass::EMBEDDED;
|
|
}
|
|
}
|