Updated Rector to commit 068799f59b289bef06b9c1f384df4301b19e726e

068799f59b [Performance] Early skip func call name on ClassRenamer (#5837)
This commit is contained in:
Tomas Votruba 2024-04-21 13:28:31 +00:00
parent 1c323223b2
commit 6cbc8ec497
12 changed files with 198 additions and 11 deletions

View File

@ -1319,7 +1319,10 @@ return array(
'Rector\\Doctrine\\CodeQuality\\AttributeTransformer\\PropertyAttributeTransformer\\IdAttributeTransformer' => $vendorDir . '/rector/rector-doctrine/rules/CodeQuality/AttributeTransformer/PropertyAttributeTransformer/IdAttributeTransformer.php',
'Rector\\Doctrine\\CodeQuality\\AttributeTransformer\\PropertyAttributeTransformer\\IdColumnAttributeTransformer' => $vendorDir . '/rector/rector-doctrine/rules/CodeQuality/AttributeTransformer/PropertyAttributeTransformer/IdColumnAttributeTransformer.php',
'Rector\\Doctrine\\CodeQuality\\AttributeTransformer\\PropertyAttributeTransformer\\IdGeneratorAttributeTransformer' => $vendorDir . '/rector/rector-doctrine/rules/CodeQuality/AttributeTransformer/PropertyAttributeTransformer/IdGeneratorAttributeTransformer.php',
'Rector\\Doctrine\\CodeQuality\\AttributeTransformer\\PropertyAttributeTransformer\\InverseJoinColumnAttributeTransformer' => $vendorDir . '/rector/rector-doctrine/rules/CodeQuality/AttributeTransformer/PropertyAttributeTransformer/InverseJoinColumnAttributeTransformer.php',
'Rector\\Doctrine\\CodeQuality\\AttributeTransformer\\PropertyAttributeTransformer\\JoinColumnAttributeTransformer' => $vendorDir . '/rector/rector-doctrine/rules/CodeQuality/AttributeTransformer/PropertyAttributeTransformer/JoinColumnAttributeTransformer.php',
'Rector\\Doctrine\\CodeQuality\\AttributeTransformer\\PropertyAttributeTransformer\\JoinTableAttributeTransformer' => $vendorDir . '/rector/rector-doctrine/rules/CodeQuality/AttributeTransformer/PropertyAttributeTransformer/JoinTableAttributeTransformer.php',
'Rector\\Doctrine\\CodeQuality\\AttributeTransformer\\PropertyAttributeTransformer\\ManyToManyAttributeTransformer' => $vendorDir . '/rector/rector-doctrine/rules/CodeQuality/AttributeTransformer/PropertyAttributeTransformer/ManyToManyAttributeTransformer.php',
'Rector\\Doctrine\\CodeQuality\\AttributeTransformer\\PropertyAttributeTransformer\\ManyToOneAttributeTransformer' => $vendorDir . '/rector/rector-doctrine/rules/CodeQuality/AttributeTransformer/PropertyAttributeTransformer/ManyToOneAttributeTransformer.php',
'Rector\\Doctrine\\CodeQuality\\AttributeTransformer\\PropertyAttributeTransformer\\OneToManyAttributeTransformer' => $vendorDir . '/rector/rector-doctrine/rules/CodeQuality/AttributeTransformer/PropertyAttributeTransformer/OneToManyAttributeTransformer.php',
'Rector\\Doctrine\\CodeQuality\\AttributeTransformer\\PropertyAttributeTransformer\\OrderByAttributeTransformer' => $vendorDir . '/rector/rector-doctrine/rules/CodeQuality/AttributeTransformer/PropertyAttributeTransformer/OrderByAttributeTransformer.php',

View File

@ -1538,7 +1538,10 @@ class ComposerStaticInit005507a96a37a412a8adf9cfaae1e621
'Rector\\Doctrine\\CodeQuality\\AttributeTransformer\\PropertyAttributeTransformer\\IdAttributeTransformer' => __DIR__ . '/..' . '/rector/rector-doctrine/rules/CodeQuality/AttributeTransformer/PropertyAttributeTransformer/IdAttributeTransformer.php',
'Rector\\Doctrine\\CodeQuality\\AttributeTransformer\\PropertyAttributeTransformer\\IdColumnAttributeTransformer' => __DIR__ . '/..' . '/rector/rector-doctrine/rules/CodeQuality/AttributeTransformer/PropertyAttributeTransformer/IdColumnAttributeTransformer.php',
'Rector\\Doctrine\\CodeQuality\\AttributeTransformer\\PropertyAttributeTransformer\\IdGeneratorAttributeTransformer' => __DIR__ . '/..' . '/rector/rector-doctrine/rules/CodeQuality/AttributeTransformer/PropertyAttributeTransformer/IdGeneratorAttributeTransformer.php',
'Rector\\Doctrine\\CodeQuality\\AttributeTransformer\\PropertyAttributeTransformer\\InverseJoinColumnAttributeTransformer' => __DIR__ . '/..' . '/rector/rector-doctrine/rules/CodeQuality/AttributeTransformer/PropertyAttributeTransformer/InverseJoinColumnAttributeTransformer.php',
'Rector\\Doctrine\\CodeQuality\\AttributeTransformer\\PropertyAttributeTransformer\\JoinColumnAttributeTransformer' => __DIR__ . '/..' . '/rector/rector-doctrine/rules/CodeQuality/AttributeTransformer/PropertyAttributeTransformer/JoinColumnAttributeTransformer.php',
'Rector\\Doctrine\\CodeQuality\\AttributeTransformer\\PropertyAttributeTransformer\\JoinTableAttributeTransformer' => __DIR__ . '/..' . '/rector/rector-doctrine/rules/CodeQuality/AttributeTransformer/PropertyAttributeTransformer/JoinTableAttributeTransformer.php',
'Rector\\Doctrine\\CodeQuality\\AttributeTransformer\\PropertyAttributeTransformer\\ManyToManyAttributeTransformer' => __DIR__ . '/..' . '/rector/rector-doctrine/rules/CodeQuality/AttributeTransformer/PropertyAttributeTransformer/ManyToManyAttributeTransformer.php',
'Rector\\Doctrine\\CodeQuality\\AttributeTransformer\\PropertyAttributeTransformer\\ManyToOneAttributeTransformer' => __DIR__ . '/..' . '/rector/rector-doctrine/rules/CodeQuality/AttributeTransformer/PropertyAttributeTransformer/ManyToOneAttributeTransformer.php',
'Rector\\Doctrine\\CodeQuality\\AttributeTransformer\\PropertyAttributeTransformer\\OneToManyAttributeTransformer' => __DIR__ . '/..' . '/rector/rector-doctrine/rules/CodeQuality/AttributeTransformer/PropertyAttributeTransformer/OneToManyAttributeTransformer.php',
'Rector\\Doctrine\\CodeQuality\\AttributeTransformer\\PropertyAttributeTransformer\\OrderByAttributeTransformer' => __DIR__ . '/..' . '/rector/rector-doctrine/rules/CodeQuality/AttributeTransformer/PropertyAttributeTransformer/OrderByAttributeTransformer.php',

View File

@ -1679,12 +1679,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-doctrine.git",
"reference": "9e0a97b087071637e35eda5c7596704ee137a082"
"reference": "ea7e84438061f3c39c59cb029e6c55b39002d8f8"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-doctrine\/zipball\/9e0a97b087071637e35eda5c7596704ee137a082",
"reference": "9e0a97b087071637e35eda5c7596704ee137a082",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-doctrine\/zipball\/ea7e84438061f3c39c59cb029e6c55b39002d8f8",
"reference": "ea7e84438061f3c39c59cb029e6c55b39002d8f8",
"shasum": ""
},
"require": {
@ -1709,7 +1709,7 @@
"tomasvotruba\/unused-public": "^0.3",
"tracy\/tracy": "^2.10"
},
"time": "2024-04-21T12:41:39+00:00",
"time": "2024-04-21T13:25:07+00:00",
"default-branch": true,
"type": "rector-extension",
"extra": {

File diff suppressed because one or more lines are too long

View File

@ -9,7 +9,7 @@ namespace Rector\RectorInstaller;
*/
final class GeneratedConfig
{
public const EXTENSIONS = array('rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => NULL, 'version' => 'dev-main 9e0a97b'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => NULL, 'version' => 'dev-main 05e44cf'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => NULL, 'version' => 'dev-main e8af39b'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => NULL, 'version' => 'dev-main b8126e8'));
public const EXTENSIONS = array('rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => NULL, 'version' => 'dev-main ea7e844'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => NULL, 'version' => 'dev-main 05e44cf'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => NULL, 'version' => 'dev-main e8af39b'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => NULL, 'version' => 'dev-main b8126e8'));
private function __construct()
{
}

View File

@ -15,7 +15,10 @@ use Rector\Doctrine\CodeQuality\AttributeTransformer\PropertyAttributeTransforme
use Rector\Doctrine\CodeQuality\AttributeTransformer\PropertyAttributeTransformer\IdAttributeTransformer;
use Rector\Doctrine\CodeQuality\AttributeTransformer\PropertyAttributeTransformer\IdColumnAttributeTransformer;
use Rector\Doctrine\CodeQuality\AttributeTransformer\PropertyAttributeTransformer\IdGeneratorAttributeTransformer;
use Rector\Doctrine\CodeQuality\AttributeTransformer\PropertyAttributeTransformer\InverseJoinColumnAttributeTransformer;
use Rector\Doctrine\CodeQuality\AttributeTransformer\PropertyAttributeTransformer\JoinColumnAttributeTransformer;
use Rector\Doctrine\CodeQuality\AttributeTransformer\PropertyAttributeTransformer\JoinTableAttributeTransformer;
use Rector\Doctrine\CodeQuality\AttributeTransformer\PropertyAttributeTransformer\ManyToManyAttributeTransformer;
use Rector\Doctrine\CodeQuality\AttributeTransformer\PropertyAttributeTransformer\ManyToOneAttributeTransformer;
use Rector\Doctrine\CodeQuality\AttributeTransformer\PropertyAttributeTransformer\OneToManyAttributeTransformer;
use Rector\Doctrine\CodeQuality\AttributeTransformer\PropertyAttributeTransformer\OrderByAttributeTransformer;
@ -38,9 +41,12 @@ return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->singleton(IdAttributeTransformer::class);
$rectorConfig->singleton(IdColumnAttributeTransformer::class);
$rectorConfig->singleton(IdGeneratorAttributeTransformer::class);
$rectorConfig->singleton(ManyToManyAttributeTransformer::class);
$rectorConfig->singleton(ManyToOneAttributeTransformer::class);
$rectorConfig->singleton(OneToManyAttributeTransformer::class);
$rectorConfig->singleton(JoinTableAttributeTransformer::class);
$rectorConfig->singleton(JoinColumnAttributeTransformer::class);
$rectorConfig->singleton(InverseJoinColumnAttributeTransformer::class);
$rectorConfig->singleton(OrderByAttributeTransformer::class);
$rectorConfig->when(YamlToAttributeTransformer::class)->needs('$classAttributeTransformers')->giveTagged(ClassAttributeTransformerInterface::class);
$rectorConfig->when(YamlToAttributeTransformer::class)->needs('$propertyAttributeTransformers')->giveTagged(PropertyAttributeTransformerInterface::class);

View File

@ -0,0 +1,56 @@
<?php
declare (strict_types=1);
namespace Rector\Doctrine\CodeQuality\AttributeTransformer\PropertyAttributeTransformer;
use PhpParser\Node\AttributeGroup;
use PhpParser\Node\Param;
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;
use Rector\PhpParser\Node\NodeFactory;
final class InverseJoinColumnAttributeTransformer implements PropertyAttributeTransformerInterface
{
/**
* @readonly
* @var \Rector\PhpParser\Node\NodeFactory
*/
private $nodeFactory;
public function __construct(NodeFactory $nodeFactory)
{
$this->nodeFactory = $nodeFactory;
}
/**
* @param \PhpParser\Node\Stmt\Property|\PhpParser\Node\Param $property
*/
public function transform(EntityMapping $entityMapping, $property) : void
{
$joinTableMapping = $entityMapping->matchManyToManyPropertyMapping($property)['joinTable'] ?? null;
if (!\is_array($joinTableMapping)) {
return;
}
$joinColumns = $joinTableMapping['inverseJoinColumns'] ?? null;
if (!\is_array($joinColumns)) {
return;
}
foreach ($joinColumns as $columnName => $joinColumn) {
$property->attrGroups[] = $this->createInverseJoinColumnAttrGroup($columnName, $joinColumn);
}
}
public function getClassName() : string
{
return MappingClass::INVERSE_JOIN_COLUMN;
}
/**
* @param int|string $columnName
* @param mixed $joinColumn
*/
private function createInverseJoinColumnAttrGroup($columnName, $joinColumn) : AttributeGroup
{
$joinColumn = \array_merge(['name' => $columnName], $joinColumn);
$args = $this->nodeFactory->createArgs($joinColumn);
return AttributeFactory::createGroup($this->getClassName(), $args);
}
}

View File

@ -27,17 +27,25 @@ final class JoinColumnAttributeTransformer implements PropertyAttributeTransform
*/
public function transform(EntityMapping $entityMapping, $property) : void
{
$manyToOnePropertyMapping = $entityMapping->matchManyToOnePropertyMapping($property);
if (!\is_array($manyToOnePropertyMapping)) {
$this->transformMapping($property, $entityMapping->matchManyToManyPropertyMapping($property)['joinTable'] ?? null);
$this->transformMapping($property, $entityMapping->matchManyToOnePropertyMapping($property));
}
/**
* @param array<string, array<string, mixed>>|null $mapping
* @param \PhpParser\Node\Stmt\Property|\PhpParser\Node\Param $property
*/
private function transformMapping($property, ?array $mapping) : void
{
if (!\is_array($mapping)) {
return;
}
$singleJoinColumn = $manyToOnePropertyMapping['joinColumn'] ?? null;
$singleJoinColumn = $mapping['joinColumn'] ?? null;
if (\is_array($singleJoinColumn)) {
$name = $singleJoinColumn['name'];
unset($singleJoinColumn['name']);
$manyToOnePropertyMapping['joinColumns'][$name] = $singleJoinColumn;
$mapping['joinColumns'][$name] = $singleJoinColumn;
}
$joinColumns = $manyToOnePropertyMapping['joinColumns'] ?? null;
$joinColumns = $mapping['joinColumns'] ?? null;
if (!\is_array($joinColumns)) {
return;
}

View File

@ -0,0 +1,45 @@
<?php
declare (strict_types=1);
namespace Rector\Doctrine\CodeQuality\AttributeTransformer\PropertyAttributeTransformer;
use PhpParser\Node\Param;
use PhpParser\Node\Stmt\Property;
use Rector\Doctrine\CodeQuality\Contract\PropertyAttributeTransformerInterface;
use Rector\Doctrine\CodeQuality\Enum\EntityMappingKey;
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 JoinTableAttributeTransformer implements PropertyAttributeTransformerInterface
{
/**
* @readonly
* @var \Rector\PhpParser\Node\NodeFactory
*/
private $nodeFactory;
public function __construct(NodeFactory $nodeFactory)
{
$this->nodeFactory = $nodeFactory;
}
/**
* @param \PhpParser\Node\Stmt\Property|\PhpParser\Node\Param $property
*/
public function transform(EntityMapping $entityMapping, $property) : void
{
$joinTableMapping = $entityMapping->matchManyToManyPropertyMapping($property)['joinTable'] ?? null;
if (!\is_array($joinTableMapping)) {
return;
}
// handled by another mapper
unset($joinTableMapping['joinColumns'], $joinTableMapping['inverseJoinColumns']);
$args = $this->nodeFactory->createArgs($joinTableMapping);
$property->attrGroups[] = AttributeFactory::createGroup($this->getClassName(), $args);
NodeValueNormalizer::ensureKeyIsClassConstFetch($args, EntityMappingKey::TARGET_ENTITY);
}
public function getClassName() : string
{
return MappingClass::JOIN_TABLE;
}
}

View File

@ -0,0 +1,45 @@
<?php
declare (strict_types=1);
namespace Rector\Doctrine\CodeQuality\AttributeTransformer\PropertyAttributeTransformer;
use PhpParser\Node\Param;
use PhpParser\Node\Stmt\Property;
use Rector\Doctrine\CodeQuality\Contract\PropertyAttributeTransformerInterface;
use Rector\Doctrine\CodeQuality\Enum\EntityMappingKey;
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 ManyToManyAttributeTransformer implements PropertyAttributeTransformerInterface
{
/**
* @readonly
* @var \Rector\PhpParser\Node\NodeFactory
*/
private $nodeFactory;
public function __construct(NodeFactory $nodeFactory)
{
$this->nodeFactory = $nodeFactory;
}
/**
* @param \PhpParser\Node\Stmt\Property|\PhpParser\Node\Param $property
*/
public function transform(EntityMapping $entityMapping, $property) : void
{
$manyToManyMapping = $entityMapping->matchManyToManyPropertyMapping($property);
if (!\is_array($manyToManyMapping)) {
return;
}
// handled by another mapper
unset($manyToManyMapping['joinTable']);
$args = $this->nodeFactory->createArgs($manyToManyMapping);
$property->attrGroups[] = AttributeFactory::createGroup($this->getClassName(), $args);
NodeValueNormalizer::ensureKeyIsClassConstFetch($args, EntityMappingKey::TARGET_ENTITY);
}
public function getClassName() : string
{
return MappingClass::MANY_TO_MANY;
}
}

View File

@ -50,6 +50,15 @@ final class EntityMapping
$propertyName = $this->getPropertyName($property);
return $this->entityMapping['embedded'][$propertyName] ?? null;
}
/**
* @return array<string, mixed>|null
* @param \PhpParser\Node\Stmt\Property|\PhpParser\Node\Param $property
*/
public function matchManyToManyPropertyMapping($property) : ?array
{
$propertyName = $this->getPropertyName($property);
return $this->entityMapping['manyToMany'][$propertyName] ?? null;
}
/**
* @return array<string, mixed>|null
* @param \PhpParser\Node\Stmt\Property|\PhpParser\Node\Param $property

View File

@ -57,6 +57,18 @@ final class MappingClass
* @var string
*/
public const INDEX = 'Doctrine\\ORM\\Mapping\\Index';
/**
* @var string
*/
public const INVERSE_JOIN_COLUMN = 'Doctrine\\ORM\\Mapping\\InverseJoinColumn';
/**
* @var string
*/
public const JOIN_TABLE = 'Doctrine\\ORM\\Mapping\\JoinTable';
/**
* @var string
*/
public const MANY_TO_MANY = 'Doctrine\\ORM\\Mapping\\ManyToMany';
/**
* @var string
*/