mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-17 21:38:22 +01:00
Updated Rector to commit c4dd05e2e3ae6359ff4eb57ce7d7bd7619da139d
c4dd05e2e3
[CodeQuality] Add StaticToSelfStaticMethodCallOnFinalClassRector (#5621)
This commit is contained in:
parent
6ef7f81fc3
commit
faf7fee8e4
8
vendor/composer/installed.json
vendored
8
vendor/composer/installed.json
vendored
@ -1679,12 +1679,12 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/rectorphp\/rector-doctrine.git",
|
||||
"reference": "cc219a306d81cbfa263baa7e2a3e7a9daa663903"
|
||||
"reference": "c44beb36a11bcc763ef4b65654c44d503bd158d4"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-doctrine\/zipball\/cc219a306d81cbfa263baa7e2a3e7a9daa663903",
|
||||
"reference": "cc219a306d81cbfa263baa7e2a3e7a9daa663903",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-doctrine\/zipball\/c44beb36a11bcc763ef4b65654c44d503bd158d4",
|
||||
"reference": "c44beb36a11bcc763ef4b65654c44d503bd158d4",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -1709,7 +1709,7 @@
|
||||
"tomasvotruba\/unused-public": "^0.3",
|
||||
"tracy\/tracy": "^2.10"
|
||||
},
|
||||
"time": "2024-02-15T09:34:20+00:00",
|
||||
"time": "2024-02-15T14:46:39+00:00",
|
||||
"default-branch": true,
|
||||
"type": "rector-extension",
|
||||
"extra": {
|
||||
|
2
vendor/composer/installed.php
vendored
2
vendor/composer/installed.php
vendored
File diff suppressed because one or more lines are too long
@ -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 cc219a3'), '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 8d1aab2'), '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 cdbe390'), '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 59edb62'));
|
||||
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 c44beb3'), '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 8d1aab2'), '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 cdbe390'), '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 59edb62'));
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
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;
|
||||
@ -21,7 +22,10 @@ final class ColumnAttributeTransformer implements PropertyAttributeTransformerIn
|
||||
{
|
||||
$this->nodeFactory = $nodeFactory;
|
||||
}
|
||||
public function transform(EntityMapping $entityMapping, Property $property) : void
|
||||
/**
|
||||
* @param \PhpParser\Node\Stmt\Property|\PhpParser\Node\Param $property
|
||||
*/
|
||||
public function transform(EntityMapping $entityMapping, $property) : void
|
||||
{
|
||||
$propertyMapping = $entityMapping->matchFieldPropertyMapping($property);
|
||||
if ($propertyMapping === null) {
|
||||
|
@ -3,6 +3,7 @@
|
||||
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\Helper\NodeValueNormalizer;
|
||||
@ -21,7 +22,10 @@ final class EmbeddedPropertyAttributeTransformer implements PropertyAttributeTra
|
||||
{
|
||||
$this->nodeFactory = $nodeFactory;
|
||||
}
|
||||
public function transform(EntityMapping $entityMapping, Property $property) : void
|
||||
/**
|
||||
* @param \PhpParser\Node\Stmt\Property|\PhpParser\Node\Param $property
|
||||
*/
|
||||
public function transform(EntityMapping $entityMapping, $property) : void
|
||||
{
|
||||
$propertyMapping = $entityMapping->matchEmbeddedPropertyMapping($property);
|
||||
if ($propertyMapping === null) {
|
||||
|
@ -3,6 +3,7 @@
|
||||
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\NodeFactory\AttributeFactory;
|
||||
@ -20,7 +21,10 @@ final class GedmoTimestampableAttributeTransformer implements PropertyAttributeT
|
||||
{
|
||||
$this->nodeFactory = $nodeFactory;
|
||||
}
|
||||
public function transform(EntityMapping $entityMapping, Property $property) : void
|
||||
/**
|
||||
* @param \PhpParser\Node\Stmt\Property|\PhpParser\Node\Param $property
|
||||
*/
|
||||
public function transform(EntityMapping $entityMapping, $property) : void
|
||||
{
|
||||
$fieldPropertyMapping = $entityMapping->matchFieldPropertyMapping($property);
|
||||
$timestampableMapping = $fieldPropertyMapping['gedmo']['timestampable'] ?? null;
|
||||
|
@ -3,6 +3,7 @@
|
||||
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\NodeFactory\AttributeFactory;
|
||||
@ -10,7 +11,10 @@ use Rector\Doctrine\CodeQuality\ValueObject\EntityMapping;
|
||||
use Rector\Doctrine\Enum\MappingClass;
|
||||
final class IdAttributeTransformer implements PropertyAttributeTransformerInterface
|
||||
{
|
||||
public function transform(EntityMapping $entityMapping, Property $property) : void
|
||||
/**
|
||||
* @param \PhpParser\Node\Stmt\Property|\PhpParser\Node\Param $property
|
||||
*/
|
||||
public function transform(EntityMapping $entityMapping, $property) : void
|
||||
{
|
||||
$idMapping = $entityMapping->matchIdPropertyMapping($property);
|
||||
if (!\is_array($idMapping)) {
|
||||
|
@ -3,6 +3,7 @@
|
||||
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\NodeFactory\AttributeFactory;
|
||||
@ -10,7 +11,10 @@ use Rector\Doctrine\CodeQuality\ValueObject\EntityMapping;
|
||||
use Rector\Doctrine\Enum\MappingClass;
|
||||
final class IdColumnAttributeTransformer implements PropertyAttributeTransformerInterface
|
||||
{
|
||||
public function transform(EntityMapping $entityMapping, Property $property) : void
|
||||
/**
|
||||
* @param \PhpParser\Node\Stmt\Property|\PhpParser\Node\Param $property
|
||||
*/
|
||||
public function transform(EntityMapping $entityMapping, $property) : void
|
||||
{
|
||||
$idMapping = $entityMapping->matchIdPropertyMapping($property);
|
||||
if (!\is_array($idMapping)) {
|
||||
|
@ -3,6 +3,7 @@
|
||||
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;
|
||||
@ -27,7 +28,10 @@ final class IdGeneratorAttributeTransformer implements PropertyAttributeTransfor
|
||||
// private ArrayItemNodeFactory $arrayItemNodeFactory
|
||||
$this->nodeFactory = $nodeFactory;
|
||||
}
|
||||
public function transform(EntityMapping $entityMapping, Property $property) : void
|
||||
/**
|
||||
* @param \PhpParser\Node\Stmt\Property|\PhpParser\Node\Param $property
|
||||
*/
|
||||
public function transform(EntityMapping $entityMapping, $property) : void
|
||||
{
|
||||
$idMapping = $entityMapping->matchIdPropertyMapping($property);
|
||||
if (!\is_array($idMapping)) {
|
||||
|
@ -4,6 +4,7 @@ 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;
|
||||
@ -21,7 +22,10 @@ final class JoinColumnAttributeTransformer implements PropertyAttributeTransform
|
||||
{
|
||||
$this->nodeFactory = $nodeFactory;
|
||||
}
|
||||
public function transform(EntityMapping $entityMapping, Property $property) : void
|
||||
/**
|
||||
* @param \PhpParser\Node\Stmt\Property|\PhpParser\Node\Param $property
|
||||
*/
|
||||
public function transform(EntityMapping $entityMapping, $property) : void
|
||||
{
|
||||
$manyToOnePropertyMapping = $entityMapping->matchManyToOnePropertyMapping($property);
|
||||
if (!\is_array($manyToOnePropertyMapping)) {
|
||||
|
@ -3,6 +3,7 @@
|
||||
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;
|
||||
@ -22,7 +23,10 @@ final class ManyToOneAttributeTransformer implements PropertyAttributeTransforme
|
||||
{
|
||||
$this->nodeFactory = $nodeFactory;
|
||||
}
|
||||
public function transform(EntityMapping $entityMapping, Property $property) : void
|
||||
/**
|
||||
* @param \PhpParser\Node\Stmt\Property|\PhpParser\Node\Param $property
|
||||
*/
|
||||
public function transform(EntityMapping $entityMapping, $property) : void
|
||||
{
|
||||
$manyToOneMapping = $entityMapping->matchManyToOnePropertyMapping($property);
|
||||
if (!\is_array($manyToOneMapping)) {
|
||||
|
@ -3,6 +3,7 @@
|
||||
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;
|
||||
@ -22,7 +23,10 @@ final class OneToManyAttributeTransformer implements PropertyAttributeTransforme
|
||||
{
|
||||
$this->nodeFactory = $nodeFactory;
|
||||
}
|
||||
public function transform(EntityMapping $entityMapping, Property $property) : void
|
||||
/**
|
||||
* @param \PhpParser\Node\Stmt\Property|\PhpParser\Node\Param $property
|
||||
*/
|
||||
public function transform(EntityMapping $entityMapping, $property) : void
|
||||
{
|
||||
$oneToManyMapping = $entityMapping->matchOneToManyPropertyMapping($property);
|
||||
if (!\is_array($oneToManyMapping)) {
|
||||
|
@ -3,6 +3,7 @@
|
||||
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;
|
||||
@ -21,7 +22,10 @@ final class OrderByAttributeTransformer implements PropertyAttributeTransformerI
|
||||
{
|
||||
$this->nodeFactory = $nodeFactory;
|
||||
}
|
||||
public function transform(EntityMapping $entityMapping, Property $property) : void
|
||||
/**
|
||||
* @param \PhpParser\Node\Stmt\Property|\PhpParser\Node\Param $property
|
||||
*/
|
||||
public function transform(EntityMapping $entityMapping, $property) : void
|
||||
{
|
||||
$oneToManyMapping = $entityMapping->matchOneToManyPropertyMapping($property);
|
||||
if (!\is_array($oneToManyMapping)) {
|
||||
|
@ -3,11 +3,14 @@
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Doctrine\CodeQuality\AttributeTransformer;
|
||||
|
||||
use PhpParser\Node\Param;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use PhpParser\Node\Stmt\Property;
|
||||
use Rector\Doctrine\CodeQuality\Contract\ClassAttributeTransformerInterface;
|
||||
use Rector\Doctrine\CodeQuality\Contract\PropertyAttributeTransformerInterface;
|
||||
use Rector\Doctrine\CodeQuality\ValueObject\EntityMapping;
|
||||
use Rector\ValueObject\MethodName;
|
||||
final class YamlToAttributeTransformer
|
||||
{
|
||||
/**
|
||||
@ -53,9 +56,26 @@ final class YamlToAttributeTransformer
|
||||
$propertyAttributeTransformer->transform($entityMapping, $property);
|
||||
}
|
||||
}
|
||||
// handle promoted properties
|
||||
$constructorClassMethod = $class->getMethod(MethodName::CONSTRUCT);
|
||||
if (!$constructorClassMethod instanceof ClassMethod) {
|
||||
return;
|
||||
}
|
||||
foreach ($constructorClassMethod->getParams() as $param) {
|
||||
// is promoted property?
|
||||
if ($param->flags === 0) {
|
||||
continue;
|
||||
}
|
||||
foreach ($this->propertyAttributeTransformers as $propertyAttributeTransformer) {
|
||||
if ($this->hasAttribute($param, $propertyAttributeTransformer->getClassName())) {
|
||||
continue;
|
||||
}
|
||||
$propertyAttributeTransformer->transform($entityMapping, $param);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @param \PhpParser\Node\Stmt\Class_|\PhpParser\Node\Stmt\Property $stmt
|
||||
* @param \PhpParser\Node\Stmt\Class_|\PhpParser\Node\Stmt\Property|\PhpParser\Node\Param $stmt
|
||||
*/
|
||||
private function hasAttribute($stmt, string $attributeClassName) : bool
|
||||
{
|
||||
|
@ -3,10 +3,17 @@
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Doctrine\CodeQuality\Contract;
|
||||
|
||||
use PhpParser\Node\Param;
|
||||
use PhpParser\Node\Stmt\Property;
|
||||
use Rector\Doctrine\CodeQuality\ValueObject\EntityMapping;
|
||||
interface PropertyAttributeTransformerInterface
|
||||
{
|
||||
/**
|
||||
* @return MappingClass::*
|
||||
*/
|
||||
public function getClassName() : string;
|
||||
public function transform(EntityMapping $entityMapping, Property $property) : void;
|
||||
/**
|
||||
* @param \PhpParser\Node\Stmt\Property|\PhpParser\Node\Param $property
|
||||
*/
|
||||
public function transform(EntityMapping $entityMapping, $property) : void;
|
||||
}
|
||||
|
@ -3,7 +3,10 @@
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Doctrine\CodeQuality\ValueObject;
|
||||
|
||||
use PhpParser\Node\Expr\Variable;
|
||||
use PhpParser\Node\Param;
|
||||
use PhpParser\Node\Stmt\Property;
|
||||
use Rector\Exception\ShouldNotHappenException;
|
||||
use RectorPrefix202402\Webmozart\Assert\Assert;
|
||||
final class EntityMapping
|
||||
{
|
||||
@ -31,32 +34,36 @@ final class EntityMapping
|
||||
}
|
||||
/**
|
||||
* @return mixed[]|null
|
||||
* @param \PhpParser\Node\Stmt\Property|\PhpParser\Node\Param $property
|
||||
*/
|
||||
public function matchFieldPropertyMapping(Property $property) : ?array
|
||||
public function matchFieldPropertyMapping($property) : ?array
|
||||
{
|
||||
$propertyName = $this->getPropertyName($property);
|
||||
return $this->entityMapping['fields'][$propertyName] ?? null;
|
||||
}
|
||||
/**
|
||||
* @return mixed[]|null
|
||||
* @param \PhpParser\Node\Stmt\Property|\PhpParser\Node\Param $property
|
||||
*/
|
||||
public function matchEmbeddedPropertyMapping(Property $property) : ?array
|
||||
public function matchEmbeddedPropertyMapping($property) : ?array
|
||||
{
|
||||
$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 matchManyToOnePropertyMapping(Property $property) : ?array
|
||||
public function matchManyToOnePropertyMapping($property) : ?array
|
||||
{
|
||||
$propertyName = $this->getPropertyName($property);
|
||||
return $this->entityMapping['manyToOne'][$propertyName] ?? null;
|
||||
}
|
||||
/**
|
||||
* @return array<string, mixed>|null
|
||||
* @param \PhpParser\Node\Stmt\Property|\PhpParser\Node\Param $property
|
||||
*/
|
||||
public function matchOneToManyPropertyMapping(Property $property) : ?array
|
||||
public function matchOneToManyPropertyMapping($property) : ?array
|
||||
{
|
||||
$propertyName = $this->getPropertyName($property);
|
||||
return $this->entityMapping['oneToMany'][$propertyName] ?? null;
|
||||
@ -73,14 +80,26 @@ final class EntityMapping
|
||||
}
|
||||
/**
|
||||
* @return array<string, mixed>|null
|
||||
* @param \PhpParser\Node\Stmt\Property|\PhpParser\Node\Param $property
|
||||
*/
|
||||
public function matchIdPropertyMapping(Property $property) : ?array
|
||||
public function matchIdPropertyMapping($property) : ?array
|
||||
{
|
||||
$propertyName = $this->getPropertyName($property);
|
||||
return $this->entityMapping['id'][$propertyName] ?? null;
|
||||
}
|
||||
private function getPropertyName(Property $property) : string
|
||||
/**
|
||||
* @param \PhpParser\Node\Stmt\Property|\PhpParser\Node\Param $property
|
||||
*/
|
||||
private function getPropertyName($property) : string
|
||||
{
|
||||
return $property->props[0]->name->toString();
|
||||
if ($property instanceof Property) {
|
||||
return $property->props[0]->name->toString();
|
||||
}
|
||||
if ($property->var instanceof Variable) {
|
||||
$paramName = $property->var->name;
|
||||
Assert::string($paramName);
|
||||
return $paramName;
|
||||
}
|
||||
throw new ShouldNotHappenException();
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Doctrine\NodeManipulator;
|
||||
|
||||
use PhpParser\Node\Param;
|
||||
use PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Stmt\Property;
|
||||
use PHPStan\Type\Type;
|
||||
@ -88,8 +89,9 @@ final class ToManyRelationPropertyTypeResolver
|
||||
}
|
||||
/**
|
||||
* @param \PhpParser\Node\Expr|string $targetEntity
|
||||
* @param \PhpParser\Node\Stmt\Property|\PhpParser\Node\Param $property
|
||||
*/
|
||||
private function resolveTypeFromTargetEntity($targetEntity, Property $property) : Type
|
||||
private function resolveTypeFromTargetEntity($targetEntity, $property) : Type
|
||||
{
|
||||
if ($targetEntity instanceof Expr) {
|
||||
$targetEntity = $this->valueResolver->getValue($targetEntity);
|
||||
|
Loading…
x
Reference in New Issue
Block a user