mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-07 20:00:50 +00:00
Updated Rector to commit ad09d9c37e3e98eff856fcad7c355accad83f6b4
ad09d9c37e
make use of autotagInterface() (#5396)
This commit is contained in:
parent
5a2b12fcd4
commit
c079729bef
5
vendor/composer/autoload_classmap.php
vendored
5
vendor/composer/autoload_classmap.php
vendored
|
@ -1383,6 +1383,7 @@ return array(
|
|||
'Rector\\Doctrine\\Bundle210\\Rector\\Class_\\EventSubscriberInterfaceToAttributeRector' => $vendorDir . '/rector/rector-doctrine/rules/Bundle210/Rector/Class_/EventSubscriberInterfaceToAttributeRector.php',
|
||||
'Rector\\Doctrine\\CodeQuality\\AnnotationTransformer\\ClassAnnotationTransformer\\EmbeddableClassAnnotationTransformer' => $vendorDir . '/rector/rector-doctrine/rules/CodeQuality/AnnotationTransformer/ClassAnnotationTransformer/EmbeddableClassAnnotationTransformer.php',
|
||||
'Rector\\Doctrine\\CodeQuality\\AnnotationTransformer\\ClassAnnotationTransformer\\EntityClassAnnotationTransformer' => $vendorDir . '/rector/rector-doctrine/rules/CodeQuality/AnnotationTransformer/ClassAnnotationTransformer/EntityClassAnnotationTransformer.php',
|
||||
'Rector\\Doctrine\\CodeQuality\\AnnotationTransformer\\ClassAnnotationTransformer\\InheritanceClassAnnotationTransformer' => $vendorDir . '/rector/rector-doctrine/rules/CodeQuality/AnnotationTransformer/ClassAnnotationTransformer/InheritanceClassAnnotationTransformer.php',
|
||||
'Rector\\Doctrine\\CodeQuality\\AnnotationTransformer\\ClassAnnotationTransformer\\SoftDeletableClassAnnotationTransformer' => $vendorDir . '/rector/rector-doctrine/rules/CodeQuality/AnnotationTransformer/ClassAnnotationTransformer/SoftDeletableClassAnnotationTransformer.php',
|
||||
'Rector\\Doctrine\\CodeQuality\\AnnotationTransformer\\ClassAnnotationTransformer\\TableClassAnnotationTransformer' => $vendorDir . '/rector/rector-doctrine/rules/CodeQuality/AnnotationTransformer/ClassAnnotationTransformer/TableClassAnnotationTransformer.php',
|
||||
'Rector\\Doctrine\\CodeQuality\\AnnotationTransformer\\PropertyAnnotationTransformer\\ColumnAnnotationTransformer' => $vendorDir . '/rector/rector-doctrine/rules/CodeQuality/AnnotationTransformer/PropertyAnnotationTransformer/ColumnAnnotationTransformer.php',
|
||||
|
@ -1394,14 +1395,12 @@ return array(
|
|||
'Rector\\Doctrine\\CodeQuality\\AnnotationTransformer\\PropertyAnnotationTransformer\\ManyToOneAnnotationTransformer' => $vendorDir . '/rector/rector-doctrine/rules/CodeQuality/AnnotationTransformer/PropertyAnnotationTransformer/ManyToOneAnnotationTransformer.php',
|
||||
'Rector\\Doctrine\\CodeQuality\\AnnotationTransformer\\PropertyAnnotationTransformer\\OneToManyAnnotationTransformer' => $vendorDir . '/rector/rector-doctrine/rules/CodeQuality/AnnotationTransformer/PropertyAnnotationTransformer/OneToManyAnnotationTransformer.php',
|
||||
'Rector\\Doctrine\\CodeQuality\\AnnotationTransformer\\YamlToAnnotationTransformer' => $vendorDir . '/rector/rector-doctrine/rules/CodeQuality/AnnotationTransformer/YamlToAnnotationTransformer.php',
|
||||
'Rector\\Doctrine\\CodeQuality\\Contract\\AnnotationTransformerInterface' => $vendorDir . '/rector/rector-doctrine/rules/CodeQuality/Contract/AnnotationTransformerInterface.php',
|
||||
'Rector\\Doctrine\\CodeQuality\\Contract\\ClassAnnotationTransformerInterface' => $vendorDir . '/rector/rector-doctrine/rules/CodeQuality/Contract/ClassAnnotationTransformerInterface.php',
|
||||
'Rector\\Doctrine\\CodeQuality\\Contract\\PropertyAnnotationTransformerInterface' => $vendorDir . '/rector/rector-doctrine/rules/CodeQuality/Contract/PropertyAnnotationTransformerInterface.php',
|
||||
'Rector\\Doctrine\\CodeQuality\\DocTagNodeFactory' => $vendorDir . '/rector/rector-doctrine/rules/CodeQuality/DocTagNodeFactory.php',
|
||||
'Rector\\Doctrine\\CodeQuality\\EntityMappingResolver' => $vendorDir . '/rector/rector-doctrine/rules/CodeQuality/EntityMappingResolver.php',
|
||||
'Rector\\Doctrine\\CodeQuality\\Enum\\EntityMappingKey' => $vendorDir . '/rector/rector-doctrine/rules/CodeQuality/Enum/EntityMappingKey.php',
|
||||
'Rector\\Doctrine\\CodeQuality\\NodeFactory\\ArrayItemNodeFactory' => $vendorDir . '/rector/rector-doctrine/rules/CodeQuality/NodeFactory/ArrayItemNodeFactory.php',
|
||||
'Rector\\Doctrine\\CodeQuality\\Rector\\ClassMethod\\MakeEntitySetterNullabilityInSyncWithPropertyRector' => $vendorDir . '/rector/rector-doctrine/rules/CodeQuality/Rector/ClassMethod/MakeEntitySetterNullabilityInSyncWithPropertyRector.php',
|
||||
'Rector\\Doctrine\\CodeQuality\\Rector\\Class_\\InitializeDefaultEntityCollectionRector' => $vendorDir . '/rector/rector-doctrine/rules/CodeQuality/Rector/Class_/InitializeDefaultEntityCollectionRector.php',
|
||||
'Rector\\Doctrine\\CodeQuality\\Rector\\Class_\\MoveCurrentDateTimeDefaultInEntityToConstructorRector' => $vendorDir . '/rector/rector-doctrine/rules/CodeQuality/Rector/Class_/MoveCurrentDateTimeDefaultInEntityToConstructorRector.php',
|
||||
'Rector\\Doctrine\\CodeQuality\\Rector\\Class_\\RemoveEmptyTableAttributeRector' => $vendorDir . '/rector/rector-doctrine/rules/CodeQuality/Rector/Class_/RemoveEmptyTableAttributeRector.php',
|
||||
|
@ -1418,11 +1417,9 @@ return array(
|
|||
'Rector\\Doctrine\\CodeQuality\\ValueObject\\EntityMapping' => $vendorDir . '/rector/rector-doctrine/rules/CodeQuality/ValueObject/EntityMapping.php',
|
||||
'Rector\\Doctrine\\Dbal211\\Rector\\MethodCall\\ExtractArrayArgOnQueryBuilderSelectRector' => $vendorDir . '/rector/rector-doctrine/rules/Dbal211/Rector/MethodCall/ExtractArrayArgOnQueryBuilderSelectRector.php',
|
||||
'Rector\\Doctrine\\Dbal40\\Rector\\MethodCall\\ChangeCompositeExpressionAddMultipleWithWithRector' => $vendorDir . '/rector/rector-doctrine/rules/Dbal40/Rector/MethodCall/ChangeCompositeExpressionAddMultipleWithWithRector.php',
|
||||
'Rector\\Doctrine\\NodeAnalyzer\\AttributeCleaner' => $vendorDir . '/rector/rector-doctrine/src/NodeAnalyzer/AttributeCleaner.php',
|
||||
'Rector\\Doctrine\\NodeAnalyzer\\AttributeFinder' => $vendorDir . '/rector/rector-doctrine/src/NodeAnalyzer/AttributeFinder.php',
|
||||
'Rector\\Doctrine\\NodeAnalyzer\\AttrinationFinder' => $vendorDir . '/rector/rector-doctrine/src/NodeAnalyzer/AttrinationFinder.php',
|
||||
'Rector\\Doctrine\\NodeAnalyzer\\ConstructorAssignPropertyAnalyzer' => $vendorDir . '/rector/rector-doctrine/src/NodeAnalyzer/ConstructorAssignPropertyAnalyzer.php',
|
||||
'Rector\\Doctrine\\NodeAnalyzer\\SetterClassMethodAnalyzer' => $vendorDir . '/rector/rector-doctrine/src/NodeAnalyzer/SetterClassMethodAnalyzer.php',
|
||||
'Rector\\Doctrine\\NodeAnalyzer\\TargetEntityResolver' => $vendorDir . '/rector/rector-doctrine/src/NodeAnalyzer/TargetEntityResolver.php',
|
||||
'Rector\\Doctrine\\NodeFactory\\ArrayCollectionAssignFactory' => $vendorDir . '/rector/rector-doctrine/src/NodeFactory/ArrayCollectionAssignFactory.php',
|
||||
'Rector\\Doctrine\\NodeFactory\\ValueAssignFactory' => $vendorDir . '/rector/rector-doctrine/src/NodeFactory/ValueAssignFactory.php',
|
||||
|
|
5
vendor/composer/autoload_static.php
vendored
5
vendor/composer/autoload_static.php
vendored
|
@ -1601,6 +1601,7 @@ class ComposerStaticInit8339caf294dd12447c06647e5d0dc118
|
|||
'Rector\\Doctrine\\Bundle210\\Rector\\Class_\\EventSubscriberInterfaceToAttributeRector' => __DIR__ . '/..' . '/rector/rector-doctrine/rules/Bundle210/Rector/Class_/EventSubscriberInterfaceToAttributeRector.php',
|
||||
'Rector\\Doctrine\\CodeQuality\\AnnotationTransformer\\ClassAnnotationTransformer\\EmbeddableClassAnnotationTransformer' => __DIR__ . '/..' . '/rector/rector-doctrine/rules/CodeQuality/AnnotationTransformer/ClassAnnotationTransformer/EmbeddableClassAnnotationTransformer.php',
|
||||
'Rector\\Doctrine\\CodeQuality\\AnnotationTransformer\\ClassAnnotationTransformer\\EntityClassAnnotationTransformer' => __DIR__ . '/..' . '/rector/rector-doctrine/rules/CodeQuality/AnnotationTransformer/ClassAnnotationTransformer/EntityClassAnnotationTransformer.php',
|
||||
'Rector\\Doctrine\\CodeQuality\\AnnotationTransformer\\ClassAnnotationTransformer\\InheritanceClassAnnotationTransformer' => __DIR__ . '/..' . '/rector/rector-doctrine/rules/CodeQuality/AnnotationTransformer/ClassAnnotationTransformer/InheritanceClassAnnotationTransformer.php',
|
||||
'Rector\\Doctrine\\CodeQuality\\AnnotationTransformer\\ClassAnnotationTransformer\\SoftDeletableClassAnnotationTransformer' => __DIR__ . '/..' . '/rector/rector-doctrine/rules/CodeQuality/AnnotationTransformer/ClassAnnotationTransformer/SoftDeletableClassAnnotationTransformer.php',
|
||||
'Rector\\Doctrine\\CodeQuality\\AnnotationTransformer\\ClassAnnotationTransformer\\TableClassAnnotationTransformer' => __DIR__ . '/..' . '/rector/rector-doctrine/rules/CodeQuality/AnnotationTransformer/ClassAnnotationTransformer/TableClassAnnotationTransformer.php',
|
||||
'Rector\\Doctrine\\CodeQuality\\AnnotationTransformer\\PropertyAnnotationTransformer\\ColumnAnnotationTransformer' => __DIR__ . '/..' . '/rector/rector-doctrine/rules/CodeQuality/AnnotationTransformer/PropertyAnnotationTransformer/ColumnAnnotationTransformer.php',
|
||||
|
@ -1612,14 +1613,12 @@ class ComposerStaticInit8339caf294dd12447c06647e5d0dc118
|
|||
'Rector\\Doctrine\\CodeQuality\\AnnotationTransformer\\PropertyAnnotationTransformer\\ManyToOneAnnotationTransformer' => __DIR__ . '/..' . '/rector/rector-doctrine/rules/CodeQuality/AnnotationTransformer/PropertyAnnotationTransformer/ManyToOneAnnotationTransformer.php',
|
||||
'Rector\\Doctrine\\CodeQuality\\AnnotationTransformer\\PropertyAnnotationTransformer\\OneToManyAnnotationTransformer' => __DIR__ . '/..' . '/rector/rector-doctrine/rules/CodeQuality/AnnotationTransformer/PropertyAnnotationTransformer/OneToManyAnnotationTransformer.php',
|
||||
'Rector\\Doctrine\\CodeQuality\\AnnotationTransformer\\YamlToAnnotationTransformer' => __DIR__ . '/..' . '/rector/rector-doctrine/rules/CodeQuality/AnnotationTransformer/YamlToAnnotationTransformer.php',
|
||||
'Rector\\Doctrine\\CodeQuality\\Contract\\AnnotationTransformerInterface' => __DIR__ . '/..' . '/rector/rector-doctrine/rules/CodeQuality/Contract/AnnotationTransformerInterface.php',
|
||||
'Rector\\Doctrine\\CodeQuality\\Contract\\ClassAnnotationTransformerInterface' => __DIR__ . '/..' . '/rector/rector-doctrine/rules/CodeQuality/Contract/ClassAnnotationTransformerInterface.php',
|
||||
'Rector\\Doctrine\\CodeQuality\\Contract\\PropertyAnnotationTransformerInterface' => __DIR__ . '/..' . '/rector/rector-doctrine/rules/CodeQuality/Contract/PropertyAnnotationTransformerInterface.php',
|
||||
'Rector\\Doctrine\\CodeQuality\\DocTagNodeFactory' => __DIR__ . '/..' . '/rector/rector-doctrine/rules/CodeQuality/DocTagNodeFactory.php',
|
||||
'Rector\\Doctrine\\CodeQuality\\EntityMappingResolver' => __DIR__ . '/..' . '/rector/rector-doctrine/rules/CodeQuality/EntityMappingResolver.php',
|
||||
'Rector\\Doctrine\\CodeQuality\\Enum\\EntityMappingKey' => __DIR__ . '/..' . '/rector/rector-doctrine/rules/CodeQuality/Enum/EntityMappingKey.php',
|
||||
'Rector\\Doctrine\\CodeQuality\\NodeFactory\\ArrayItemNodeFactory' => __DIR__ . '/..' . '/rector/rector-doctrine/rules/CodeQuality/NodeFactory/ArrayItemNodeFactory.php',
|
||||
'Rector\\Doctrine\\CodeQuality\\Rector\\ClassMethod\\MakeEntitySetterNullabilityInSyncWithPropertyRector' => __DIR__ . '/..' . '/rector/rector-doctrine/rules/CodeQuality/Rector/ClassMethod/MakeEntitySetterNullabilityInSyncWithPropertyRector.php',
|
||||
'Rector\\Doctrine\\CodeQuality\\Rector\\Class_\\InitializeDefaultEntityCollectionRector' => __DIR__ . '/..' . '/rector/rector-doctrine/rules/CodeQuality/Rector/Class_/InitializeDefaultEntityCollectionRector.php',
|
||||
'Rector\\Doctrine\\CodeQuality\\Rector\\Class_\\MoveCurrentDateTimeDefaultInEntityToConstructorRector' => __DIR__ . '/..' . '/rector/rector-doctrine/rules/CodeQuality/Rector/Class_/MoveCurrentDateTimeDefaultInEntityToConstructorRector.php',
|
||||
'Rector\\Doctrine\\CodeQuality\\Rector\\Class_\\RemoveEmptyTableAttributeRector' => __DIR__ . '/..' . '/rector/rector-doctrine/rules/CodeQuality/Rector/Class_/RemoveEmptyTableAttributeRector.php',
|
||||
|
@ -1636,11 +1635,9 @@ class ComposerStaticInit8339caf294dd12447c06647e5d0dc118
|
|||
'Rector\\Doctrine\\CodeQuality\\ValueObject\\EntityMapping' => __DIR__ . '/..' . '/rector/rector-doctrine/rules/CodeQuality/ValueObject/EntityMapping.php',
|
||||
'Rector\\Doctrine\\Dbal211\\Rector\\MethodCall\\ExtractArrayArgOnQueryBuilderSelectRector' => __DIR__ . '/..' . '/rector/rector-doctrine/rules/Dbal211/Rector/MethodCall/ExtractArrayArgOnQueryBuilderSelectRector.php',
|
||||
'Rector\\Doctrine\\Dbal40\\Rector\\MethodCall\\ChangeCompositeExpressionAddMultipleWithWithRector' => __DIR__ . '/..' . '/rector/rector-doctrine/rules/Dbal40/Rector/MethodCall/ChangeCompositeExpressionAddMultipleWithWithRector.php',
|
||||
'Rector\\Doctrine\\NodeAnalyzer\\AttributeCleaner' => __DIR__ . '/..' . '/rector/rector-doctrine/src/NodeAnalyzer/AttributeCleaner.php',
|
||||
'Rector\\Doctrine\\NodeAnalyzer\\AttributeFinder' => __DIR__ . '/..' . '/rector/rector-doctrine/src/NodeAnalyzer/AttributeFinder.php',
|
||||
'Rector\\Doctrine\\NodeAnalyzer\\AttrinationFinder' => __DIR__ . '/..' . '/rector/rector-doctrine/src/NodeAnalyzer/AttrinationFinder.php',
|
||||
'Rector\\Doctrine\\NodeAnalyzer\\ConstructorAssignPropertyAnalyzer' => __DIR__ . '/..' . '/rector/rector-doctrine/src/NodeAnalyzer/ConstructorAssignPropertyAnalyzer.php',
|
||||
'Rector\\Doctrine\\NodeAnalyzer\\SetterClassMethodAnalyzer' => __DIR__ . '/..' . '/rector/rector-doctrine/src/NodeAnalyzer/SetterClassMethodAnalyzer.php',
|
||||
'Rector\\Doctrine\\NodeAnalyzer\\TargetEntityResolver' => __DIR__ . '/..' . '/rector/rector-doctrine/src/NodeAnalyzer/TargetEntityResolver.php',
|
||||
'Rector\\Doctrine\\NodeFactory\\ArrayCollectionAssignFactory' => __DIR__ . '/..' . '/rector/rector-doctrine/src/NodeFactory/ArrayCollectionAssignFactory.php',
|
||||
'Rector\\Doctrine\\NodeFactory\\ValueAssignFactory' => __DIR__ . '/..' . '/rector/rector-doctrine/src/NodeFactory/ValueAssignFactory.php',
|
||||
|
|
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": "a3a911a73ee7a22269c042345043de6741f9c11c"
|
||||
"reference": "6d6efeaba068e3b17f6c7d33b1a71433aada3207"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-doctrine\/zipball\/a3a911a73ee7a22269c042345043de6741f9c11c",
|
||||
"reference": "a3a911a73ee7a22269c042345043de6741f9c11c",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-doctrine\/zipball\/6d6efeaba068e3b17f6c7d33b1a71433aada3207",
|
||||
"reference": "6d6efeaba068e3b17f6c7d33b1a71433aada3207",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -1709,7 +1709,7 @@
|
|||
"tomasvotruba\/unused-public": "^0.3",
|
||||
"tracy\/tracy": "^2.10"
|
||||
},
|
||||
"time": "2023-12-26T19:35:17+00:00",
|
||||
"time": "2023-12-27T12:43:50+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 a3a911a'), '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 90fbaf5'), '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 e5120ff'), '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 1f44b34'));
|
||||
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 6d6efea'), '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 90fbaf5'), '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 e5120ff'), '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 1f44b34'));
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@ use Rector\Config\RectorConfig;
|
|||
use Rector\Doctrine\CodeQuality\Rector\Class_\InitializeDefaultEntityCollectionRector;
|
||||
use Rector\Doctrine\CodeQuality\Rector\Class_\MoveCurrentDateTimeDefaultInEntityToConstructorRector;
|
||||
use Rector\Doctrine\CodeQuality\Rector\Class_\RemoveEmptyTableAttributeRector;
|
||||
use Rector\Doctrine\CodeQuality\Rector\ClassMethod\MakeEntitySetterNullabilityInSyncWithPropertyRector;
|
||||
use Rector\Doctrine\CodeQuality\Rector\Property\CorrectDefaultTypesOnEntityPropertyRector;
|
||||
use Rector\Doctrine\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector;
|
||||
use Rector\Doctrine\CodeQuality\Rector\Property\MakeEntityDateTimePropertyDateTimeInterfaceRector;
|
||||
|
@ -21,7 +20,6 @@ use Rector\Transform\ValueObject\AttributeKeyToClassConstFetch;
|
|||
return static function (RectorConfig $rectorConfig) : void {
|
||||
$rectorConfig->rules([
|
||||
InitializeDefaultEntityCollectionRector::class,
|
||||
MakeEntitySetterNullabilityInSyncWithPropertyRector::class,
|
||||
MakeEntityDateTimePropertyDateTimeInterfaceRector::class,
|
||||
MoveCurrentDateTimeDefaultInEntityToConstructorRector::class,
|
||||
CorrectDefaultTypesOnEntityPropertyRector::class,
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix202312;
|
||||
|
||||
use Rector\Config\RectorConfig;
|
||||
/**
|
||||
* @deprecated Removed as not supporting the framework native approach and rather experimental.
|
||||
*
|
||||
* @see https://tomasvotruba.com/blog/2017/10/16/how-to-use-repository-with-doctrine-as-service-in-symfony/
|
||||
* @see https://tomasvotruba.com/blog/2018/04/02/rectify-turn-repositories-to-services-in-symfony/
|
||||
* @see https://getrector.com/blog/2021/02/08/how-to-instantly-decouple-symfony-doctrine-repository-inheritance-to-clean-composition
|
||||
*/
|
||||
return static function (RectorConfig $rectorConfig) : void {
|
||||
};
|
|
@ -6,6 +6,7 @@ namespace RectorPrefix202312;
|
|||
use Rector\Config\RectorConfig;
|
||||
use Rector\Doctrine\CodeQuality\AnnotationTransformer\ClassAnnotationTransformer\EmbeddableClassAnnotationTransformer;
|
||||
use Rector\Doctrine\CodeQuality\AnnotationTransformer\ClassAnnotationTransformer\EntityClassAnnotationTransformer;
|
||||
use Rector\Doctrine\CodeQuality\AnnotationTransformer\ClassAnnotationTransformer\InheritanceClassAnnotationTransformer;
|
||||
use Rector\Doctrine\CodeQuality\AnnotationTransformer\ClassAnnotationTransformer\SoftDeletableClassAnnotationTransformer;
|
||||
use Rector\Doctrine\CodeQuality\AnnotationTransformer\ClassAnnotationTransformer\TableClassAnnotationTransformer;
|
||||
use Rector\Doctrine\CodeQuality\AnnotationTransformer\PropertyAnnotationTransformer\ColumnAnnotationTransformer;
|
||||
|
@ -27,6 +28,7 @@ return static function (RectorConfig $rectorConfig) : void {
|
|||
$rectorConfig->singleton(SoftDeletableClassAnnotationTransformer::class);
|
||||
$rectorConfig->singleton(TableClassAnnotationTransformer::class);
|
||||
$rectorConfig->singleton(EmbeddableClassAnnotationTransformer::class);
|
||||
$rectorConfig->singleton(InheritanceClassAnnotationTransformer::class);
|
||||
$rectorConfig->singleton(ColumnAnnotationTransformer::class);
|
||||
$rectorConfig->singleton(EmbeddedPropertyAnnotationTransformer::class);
|
||||
$rectorConfig->singleton(GedmoTimestampableAnnotationTransformer::class);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# 18 Rules Overview
|
||||
# 17 Rules Overview
|
||||
|
||||
## ChangeCompositeExpressionAddMultipleWithWithRector
|
||||
|
||||
|
@ -212,36 +212,6 @@ Make maker bundle generate DateTime property accept DateTimeInterface too
|
|||
|
||||
<br>
|
||||
|
||||
## MakeEntitySetterNullabilityInSyncWithPropertyRector
|
||||
|
||||
Make nullability in setter class method with respect to property
|
||||
|
||||
- class: [`Rector\Doctrine\CodeQuality\Rector\ClassMethod\MakeEntitySetterNullabilityInSyncWithPropertyRector`](../rules/CodeQuality/Rector/ClassMethod/MakeEntitySetterNullabilityInSyncWithPropertyRector.php)
|
||||
|
||||
```diff
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* @ORM\Entity()
|
||||
*/
|
||||
class Product
|
||||
{
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="AnotherEntity")
|
||||
* @ORM\JoinColumn(nullable=false)
|
||||
*/
|
||||
private $anotherEntity;
|
||||
|
||||
- public function setAnotherEntity(?AnotherEntity $anotherEntity)
|
||||
+ public function setAnotherEntity(AnotherEntity $anotherEntity)
|
||||
{
|
||||
$this->anotherEntity = $anotherEntity;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
## MoveCurrentDateTimeDefaultInEntityToConstructorRector
|
||||
|
||||
Move default value for entity property to constructor, the safest place
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Doctrine\CodeQuality\AnnotationTransformer\ClassAnnotationTransformer;
|
||||
|
||||
use Rector\BetterPhpDocParser\PhpDoc\StringNode;
|
||||
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo;
|
||||
use Rector\BetterPhpDocParser\ValueObject\PhpDoc\DoctrineAnnotation\CurlyListNode;
|
||||
use Rector\Doctrine\CodeQuality\Contract\ClassAnnotationTransformerInterface;
|
||||
use Rector\Doctrine\CodeQuality\DocTagNodeFactory;
|
||||
use Rector\Doctrine\CodeQuality\NodeFactory\ArrayItemNodeFactory;
|
||||
use Rector\Doctrine\CodeQuality\ValueObject\EntityMapping;
|
||||
final class InheritanceClassAnnotationTransformer implements ClassAnnotationTransformerInterface
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Doctrine\CodeQuality\NodeFactory\ArrayItemNodeFactory
|
||||
*/
|
||||
private $arrayItemNodeFactory;
|
||||
public function __construct(ArrayItemNodeFactory $arrayItemNodeFactory)
|
||||
{
|
||||
$this->arrayItemNodeFactory = $arrayItemNodeFactory;
|
||||
}
|
||||
public function transform(EntityMapping $entityMapping, PhpDocInfo $classPhpDocInfo) : void
|
||||
{
|
||||
$classMapping = $entityMapping->getClassMapping();
|
||||
$inheritanceType = $classMapping['inheritanceType'] ?? null;
|
||||
if ($inheritanceType === null) {
|
||||
return;
|
||||
}
|
||||
$inheritanceStringNode = new StringNode($inheritanceType);
|
||||
$spacelessPhpDocTagNode = DocTagNodeFactory::createSpacelessPhpDocTagNode([$inheritanceStringNode], 'Doctrine\\ORM\\Mapping\\InheritanceType');
|
||||
$classPhpDocInfo->addPhpDocTagNode($spacelessPhpDocTagNode);
|
||||
if (isset($classMapping['discriminatorColumn'])) {
|
||||
$this->addDisriminatorColumn($classMapping['discriminatorColumn'], $classPhpDocInfo);
|
||||
}
|
||||
if (isset($classMapping['discriminatorMap'])) {
|
||||
$this->addDiscriminatorMap($classMapping['discriminatorMap'], $classPhpDocInfo);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @param array<string, mixed> $discriminatorColumn
|
||||
*/
|
||||
private function addDisriminatorColumn(array $discriminatorColumn, PhpDocInfo $classPhpDocInfo) : void
|
||||
{
|
||||
$arrayItemNodes = $this->arrayItemNodeFactory->create($discriminatorColumn, ['name', 'type']);
|
||||
$spacelessPhpDocTagNode = DocTagNodeFactory::createSpacelessPhpDocTagNode($arrayItemNodes, 'Doctrine\\ORM\\Mapping\\DiscriminatorColumn');
|
||||
$classPhpDocInfo->addPhpDocTagNode($spacelessPhpDocTagNode);
|
||||
}
|
||||
/**
|
||||
* @param array<string, mixed> $discriminatorMap
|
||||
*/
|
||||
private function addDiscriminatorMap(array $discriminatorMap, PhpDocInfo $classPhpDocInfo) : void
|
||||
{
|
||||
$arrayItemNodes = $this->arrayItemNodeFactory->create($discriminatorMap, [ArrayItemNodeFactory::QUOTE_ALL]);
|
||||
$curlyListNode = new CurlyListNode($arrayItemNodes);
|
||||
$spacelessPhpDocTagNode = DocTagNodeFactory::createSpacelessPhpDocTagNode([$curlyListNode], 'Doctrine\\ORM\\Mapping\\DiscriminatorMap');
|
||||
$classPhpDocInfo->addPhpDocTagNode($spacelessPhpDocTagNode);
|
||||
}
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Doctrine\CodeQuality\Contract;
|
||||
|
||||
interface AnnotationTransformerInterface
|
||||
{
|
||||
public function getClassName() : string;
|
||||
}
|
|
@ -5,7 +5,7 @@ namespace Rector\Doctrine\CodeQuality\Contract;
|
|||
|
||||
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo;
|
||||
use Rector\Doctrine\CodeQuality\ValueObject\EntityMapping;
|
||||
interface ClassAnnotationTransformerInterface extends \Rector\Doctrine\CodeQuality\Contract\AnnotationTransformerInterface
|
||||
interface ClassAnnotationTransformerInterface
|
||||
{
|
||||
public function transform(EntityMapping $entityMapping, PhpDocInfo $propertyPhpDocInfo) : void;
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ namespace Rector\Doctrine\CodeQuality\Contract;
|
|||
use PhpParser\Node\Stmt\Property;
|
||||
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo;
|
||||
use Rector\Doctrine\CodeQuality\ValueObject\EntityMapping;
|
||||
interface PropertyAnnotationTransformerInterface extends \Rector\Doctrine\CodeQuality\Contract\AnnotationTransformerInterface
|
||||
interface PropertyAnnotationTransformerInterface
|
||||
{
|
||||
public function transform(EntityMapping $entityMapping, PhpDocInfo $propertyPhpDocInfo, Property $property) : void;
|
||||
}
|
||||
|
|
|
@ -3,14 +3,14 @@
|
|||
declare (strict_types=1);
|
||||
namespace Rector\Doctrine\CodeQuality;
|
||||
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode;
|
||||
use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode;
|
||||
use Rector\BetterPhpDocParser\PhpDoc\ArrayItemNode;
|
||||
use Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode;
|
||||
use Rector\BetterPhpDocParser\PhpDoc\SpacelessPhpDocTagNode;
|
||||
final class DocTagNodeFactory
|
||||
{
|
||||
/**
|
||||
* @param ArrayItemNode[] $arrayItemNodes
|
||||
* @param PhpDocTagValueNode[] $arrayItemNodes
|
||||
*/
|
||||
public static function createSpacelessPhpDocTagNode(array $arrayItemNodes, string $className) : SpacelessPhpDocTagNode
|
||||
{
|
||||
|
|
|
@ -9,6 +9,10 @@ use Rector\Doctrine\CodeQuality\Enum\EntityMappingKey;
|
|||
use RectorPrefix202312\Webmozart\Assert\Assert;
|
||||
final class ArrayItemNodeFactory
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const QUOTE_ALL = '*';
|
||||
/**
|
||||
* These are handled in their own transformers
|
||||
*
|
||||
|
@ -21,7 +25,7 @@ final class ArrayItemNodeFactory
|
|||
*
|
||||
* @return ArrayItemNode[]
|
||||
*/
|
||||
public function create(array $propertyMapping, array $quotedFields) : array
|
||||
public function create(array $propertyMapping, array $quotedFields = []) : array
|
||||
{
|
||||
Assert::allString($quotedFields);
|
||||
$arrayItemNodes = [];
|
||||
|
@ -29,6 +33,10 @@ final class ArrayItemNodeFactory
|
|||
if (\in_array($fieldKey, self::EXTENSION_KEYS, \true)) {
|
||||
continue;
|
||||
}
|
||||
if ($quotedFields === [self::QUOTE_ALL]) {
|
||||
$arrayItemNodes[] = new ArrayItemNode(new StringNode($fieldValue), new StringNode($fieldKey));
|
||||
continue;
|
||||
}
|
||||
if (\in_array($fieldKey, $quotedFields, \true)) {
|
||||
$arrayItemNodes[] = new ArrayItemNode(new StringNode($fieldValue), $fieldKey);
|
||||
continue;
|
||||
|
|
|
@ -1,168 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Doctrine\CodeQuality\Rector\ClassMethod;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\ComplexType;
|
||||
use PhpParser\Node\NullableType;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
use PhpParser\Node\Stmt\Property;
|
||||
use PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprFalseNode;
|
||||
use Rector\BetterPhpDocParser\PhpDoc\ArrayItemNode;
|
||||
use Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode;
|
||||
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo;
|
||||
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Doctrine\NodeAnalyzer\SetterClassMethodAnalyzer;
|
||||
use Rector\Doctrine\PhpDocParser\DoctrineDocBlockResolver;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
/**
|
||||
* @see related to maker bundle https://symfony.com/doc/current/bundles/SymfonyMakerBundle/index.html
|
||||
*
|
||||
* @see \Rector\Doctrine\Tests\CodeQuality\Rector\ClassMethod\MakeEntitySetterNullabilityInSyncWithPropertyRector\MakeEntitySetterNullabilityInSyncWithPropertyRectorTest
|
||||
*/
|
||||
final class MakeEntitySetterNullabilityInSyncWithPropertyRector extends AbstractRector
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Doctrine\NodeAnalyzer\SetterClassMethodAnalyzer
|
||||
*/
|
||||
private $setterClassMethodAnalyzer;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Doctrine\PhpDocParser\DoctrineDocBlockResolver
|
||||
*/
|
||||
private $doctrineDocBlockResolver;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory
|
||||
*/
|
||||
private $phpDocInfoFactory;
|
||||
public function __construct(SetterClassMethodAnalyzer $setterClassMethodAnalyzer, DoctrineDocBlockResolver $doctrineDocBlockResolver, PhpDocInfoFactory $phpDocInfoFactory)
|
||||
{
|
||||
$this->setterClassMethodAnalyzer = $setterClassMethodAnalyzer;
|
||||
$this->doctrineDocBlockResolver = $doctrineDocBlockResolver;
|
||||
$this->phpDocInfoFactory = $phpDocInfoFactory;
|
||||
}
|
||||
public function getRuleDefinition() : RuleDefinition
|
||||
{
|
||||
return new RuleDefinition('Make nullability in setter class method with respect to property', [new CodeSample(<<<'CODE_SAMPLE'
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* @ORM\Entity()
|
||||
*/
|
||||
class Product
|
||||
{
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="AnotherEntity")
|
||||
* @ORM\JoinColumn(nullable=false)
|
||||
*/
|
||||
private $anotherEntity;
|
||||
|
||||
public function setAnotherEntity(?AnotherEntity $anotherEntity)
|
||||
{
|
||||
$this->anotherEntity = $anotherEntity;
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
, <<<'CODE_SAMPLE'
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* @ORM\Entity()
|
||||
*/
|
||||
class Product
|
||||
{
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="AnotherEntity")
|
||||
* @ORM\JoinColumn(nullable=false)
|
||||
*/
|
||||
private $anotherEntity;
|
||||
|
||||
public function setAnotherEntity(AnotherEntity $anotherEntity)
|
||||
{
|
||||
$this->anotherEntity = $anotherEntity;
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
)]);
|
||||
}
|
||||
/**
|
||||
* @return array<class-string<Node>>
|
||||
*/
|
||||
public function getNodeTypes() : array
|
||||
{
|
||||
return [Class_::class];
|
||||
}
|
||||
/**
|
||||
* @param Class_ $node
|
||||
*/
|
||||
public function refactor(Node $node) : ?Node
|
||||
{
|
||||
// is setter in doctrine?
|
||||
if (!$this->doctrineDocBlockResolver->isDoctrineEntityClass($node)) {
|
||||
return null;
|
||||
}
|
||||
$hasChanged = \false;
|
||||
foreach ($node->getMethods() as $classMethod) {
|
||||
$propertyName = $this->setterClassMethodAnalyzer->matchNullalbeClassMethodPropertyName($classMethod);
|
||||
if ($propertyName === null) {
|
||||
continue;
|
||||
}
|
||||
$property = $node->getProperty($propertyName);
|
||||
if (!$property instanceof Property) {
|
||||
continue;
|
||||
}
|
||||
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($property);
|
||||
$doctrineAnnotationTagValueNode = $phpDocInfo->getByAnnotationClass('Doctrine\\ORM\\Mapping\\ManyToOne');
|
||||
if (!$doctrineAnnotationTagValueNode instanceof DoctrineAnnotationTagValueNode) {
|
||||
continue;
|
||||
}
|
||||
$param = $classMethod->params[0];
|
||||
$paramType = $param->type;
|
||||
if (!$this->isJoinColumnNullable($phpDocInfo)) {
|
||||
// remove nullable if has one
|
||||
if (!$paramType instanceof NullableType) {
|
||||
continue;
|
||||
}
|
||||
$param->type = $paramType->type;
|
||||
$hasChanged = \true;
|
||||
continue;
|
||||
}
|
||||
// already nullable, lets skip it
|
||||
if ($paramType instanceof NullableType) {
|
||||
continue;
|
||||
}
|
||||
// we skip complex type as multiple or nullable already
|
||||
if ($paramType instanceof ComplexType) {
|
||||
continue;
|
||||
}
|
||||
// no type at all, there is nothing we can do
|
||||
if (!$paramType instanceof Node) {
|
||||
continue;
|
||||
}
|
||||
$param->type = new NullableType($paramType);
|
||||
$hasChanged = \true;
|
||||
}
|
||||
if ($hasChanged) {
|
||||
return $node;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private function isJoinColumnNullable(PhpDocInfo $phpDocInfo) : bool
|
||||
{
|
||||
$joinColumnDoctrineAnnotationTagValueNode = $phpDocInfo->getByAnnotationClass('Doctrine\\ORM\\Mapping\\JoinColumn');
|
||||
if (!$joinColumnDoctrineAnnotationTagValueNode instanceof DoctrineAnnotationTagValueNode) {
|
||||
// no join column means the join is nullable
|
||||
return \true;
|
||||
}
|
||||
$arrayItemNode = $joinColumnDoctrineAnnotationTagValueNode->getValue('nullable');
|
||||
if (!$arrayItemNode instanceof ArrayItemNode) {
|
||||
return \true;
|
||||
}
|
||||
return !$arrayItemNode->value instanceof ConstExprFalseNode;
|
||||
}
|
||||
}
|
|
@ -11,7 +11,6 @@ use Rector\Core\Rector\AbstractRector;
|
|||
use Rector\Doctrine\CodeQuality\AnnotationTransformer\YamlToAnnotationTransformer;
|
||||
use Rector\Doctrine\CodeQuality\EntityMappingResolver;
|
||||
use Rector\Doctrine\CodeQuality\ValueObject\EntityMapping;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
use RectorPrefix202312\Webmozart\Assert\Assert;
|
||||
|
|
|
@ -1,54 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Doctrine\NodeAnalyzer;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Attribute;
|
||||
use PhpParser\Node\Param;
|
||||
use PhpParser\Node\Stmt\ClassLike;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use PhpParser\Node\Stmt\Property;
|
||||
use Rector\Core\Exception\ShouldNotHappenException;
|
||||
use Rector\NodeNameResolver\NodeNameResolver;
|
||||
/**
|
||||
* @api
|
||||
*/
|
||||
final class AttributeCleaner
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Doctrine\NodeAnalyzer\AttributeFinder
|
||||
*/
|
||||
private $attributeFinder;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\NodeNameResolver\NodeNameResolver
|
||||
*/
|
||||
private $nodeNameResolver;
|
||||
public function __construct(\Rector\Doctrine\NodeAnalyzer\AttributeFinder $attributeFinder, NodeNameResolver $nodeNameResolver)
|
||||
{
|
||||
$this->attributeFinder = $attributeFinder;
|
||||
$this->nodeNameResolver = $nodeNameResolver;
|
||||
}
|
||||
/**
|
||||
* @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Property|\PhpParser\Node\Stmt\ClassLike|\PhpParser\Node\Param $node
|
||||
*/
|
||||
public function clearAttributeAndArgName($node, string $attributeClass, string $argName) : void
|
||||
{
|
||||
$attribute = $this->attributeFinder->findAttributeByClass($node, $attributeClass);
|
||||
if (!$attribute instanceof Attribute) {
|
||||
throw new ShouldNotHappenException();
|
||||
}
|
||||
foreach ($attribute->args as $key => $arg) {
|
||||
if (!$arg->name instanceof Node) {
|
||||
continue;
|
||||
}
|
||||
if (!$this->nodeNameResolver->isName($arg->name, $argName)) {
|
||||
continue;
|
||||
}
|
||||
// remove attribute
|
||||
unset($attribute->args[$key]);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -48,7 +48,6 @@ final class AttributeFinder
|
|||
return $this->findArgByName($attribute, $argName);
|
||||
}
|
||||
/**
|
||||
* @param class-string $attributeClass
|
||||
* @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Property|\PhpParser\Node\Stmt\ClassLike|\PhpParser\Node\Param $node
|
||||
*/
|
||||
public function findAttributeByClass($node, string $attributeClass) : ?Attribute
|
||||
|
@ -67,7 +66,7 @@ final class AttributeFinder
|
|||
return null;
|
||||
}
|
||||
/**
|
||||
* @param class-string[] $attributeClasses
|
||||
* @param string[] $attributeClasses
|
||||
* @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Property|\PhpParser\Node\Stmt\ClassLike|\PhpParser\Node\Param $node
|
||||
*/
|
||||
public function findAttributeByClasses($node, array $attributeClasses) : ?Attribute
|
||||
|
|
|
@ -1,107 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Doctrine\NodeAnalyzer;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\Assign;
|
||||
use PhpParser\Node\Expr\PropertyFetch;
|
||||
use PhpParser\Node\Expr\Variable;
|
||||
use PhpParser\Node\Stmt;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use PhpParser\Node\Stmt\Expression;
|
||||
use PHPStan\Reflection\Php\PhpPropertyReflection;
|
||||
use PHPStan\Type\ObjectType;
|
||||
use Rector\Core\Reflection\ReflectionResolver;
|
||||
use Rector\NodeNameResolver\NodeNameResolver;
|
||||
use Rector\NodeTypeResolver\NodeTypeResolver;
|
||||
final class SetterClassMethodAnalyzer
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\NodeTypeResolver\NodeTypeResolver
|
||||
*/
|
||||
private $nodeTypeResolver;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\NodeNameResolver\NodeNameResolver
|
||||
*/
|
||||
private $nodeNameResolver;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Core\Reflection\ReflectionResolver
|
||||
*/
|
||||
private $reflectionResolver;
|
||||
public function __construct(NodeTypeResolver $nodeTypeResolver, NodeNameResolver $nodeNameResolver, ReflectionResolver $reflectionResolver)
|
||||
{
|
||||
$this->nodeTypeResolver = $nodeTypeResolver;
|
||||
$this->nodeNameResolver = $nodeNameResolver;
|
||||
$this->reflectionResolver = $reflectionResolver;
|
||||
}
|
||||
public function matchNullalbeClassMethodPropertyName(ClassMethod $classMethod) : ?string
|
||||
{
|
||||
$propertyFetch = $this->matchNullalbeClassMethodPropertyFetch($classMethod);
|
||||
if (!$propertyFetch instanceof PropertyFetch) {
|
||||
return null;
|
||||
}
|
||||
$phpPropertyReflection = $this->reflectionResolver->resolvePropertyReflectionFromPropertyFetch($propertyFetch);
|
||||
if (!$phpPropertyReflection instanceof PhpPropertyReflection) {
|
||||
return null;
|
||||
}
|
||||
$reflectionProperty = $phpPropertyReflection->getNativeReflection();
|
||||
return $reflectionProperty->getName();
|
||||
}
|
||||
/**
|
||||
* Matches:
|
||||
*
|
||||
* public function setSomething(?Type $someValue); { <$this->someProperty> = $someValue; }
|
||||
*/
|
||||
private function matchNullalbeClassMethodPropertyFetch(ClassMethod $classMethod) : ?PropertyFetch
|
||||
{
|
||||
$propertyFetch = $this->matchSetterOnlyPropertyFetch($classMethod);
|
||||
if (!$propertyFetch instanceof PropertyFetch) {
|
||||
return null;
|
||||
}
|
||||
// is nullable param
|
||||
$onlyParam = $classMethod->params[0];
|
||||
if (!$this->nodeTypeResolver->isNullableTypeOfSpecificType($onlyParam, ObjectType::class)) {
|
||||
return null;
|
||||
}
|
||||
return $propertyFetch;
|
||||
}
|
||||
private function matchSetterOnlyPropertyFetch(ClassMethod $classMethod) : ?PropertyFetch
|
||||
{
|
||||
if (\count($classMethod->params) !== 1) {
|
||||
return null;
|
||||
}
|
||||
$stmts = (array) $classMethod->stmts;
|
||||
if (\count($stmts) !== 1) {
|
||||
return null;
|
||||
}
|
||||
$onlyStmt = $stmts[0] ?? null;
|
||||
if (!$onlyStmt instanceof Stmt) {
|
||||
return null;
|
||||
}
|
||||
if ($onlyStmt instanceof Expression) {
|
||||
$onlyStmt = $onlyStmt->expr;
|
||||
}
|
||||
if (!$onlyStmt instanceof Assign) {
|
||||
return null;
|
||||
}
|
||||
if (!$onlyStmt->var instanceof PropertyFetch) {
|
||||
return null;
|
||||
}
|
||||
$propertyFetch = $onlyStmt->var;
|
||||
if (!$this->isVariableName($propertyFetch->var, 'this')) {
|
||||
return null;
|
||||
}
|
||||
return $propertyFetch;
|
||||
}
|
||||
private function isVariableName(?Node $node, string $name) : bool
|
||||
{
|
||||
if (!$node instanceof Variable) {
|
||||
return \false;
|
||||
}
|
||||
return $this->nodeNameResolver->isName($node, $name);
|
||||
}
|
||||
}
|
|
@ -99,6 +99,6 @@ final class ToManyRelationPropertyTypeResolver
|
|||
}
|
||||
$entityFullyQualifiedClass = $this->shortClassExpander->resolveFqnTargetEntity($targetEntity, $property);
|
||||
$fullyQualifiedObjectType = new FullyQualifiedObjectType($entityFullyQualifiedClass);
|
||||
return $this->collectionTypeFactory->createGenericObjectType($fullyQualifiedObjectType);
|
||||
return $this->collectionTypeFactory->createType($fullyQualifiedObjectType);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,11 +17,6 @@ final class DoctrineSetList implements SetListInterface
|
|||
* @var string
|
||||
*/
|
||||
public const DOCTRINE_COMMON_20 = __DIR__ . '/../../config/sets/doctrine-common-20.php';
|
||||
/**
|
||||
* @deprecated Use self::DOCTRINE_DBAL_211 instead
|
||||
* @var string
|
||||
*/
|
||||
public const DOCTRINE_DBAL_210 = __DIR__ . '/../../config/sets/doctrine-dbal-210.php';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
|
@ -34,16 +29,6 @@ final class DoctrineSetList implements SetListInterface
|
|||
* @var string
|
||||
*/
|
||||
public const DOCTRINE_DBAL_40 = __DIR__ . '/../../config/sets/doctrine-dbal-40.php';
|
||||
/**
|
||||
* @deprecated Removed as not supporting the framework native approach and rather experimental
|
||||
* @var string
|
||||
*/
|
||||
public const DOCTRINE_REPOSITORY_AS_SERVICE = __DIR__ . '/../../config/sets/doctrine-repository-as-service.php';
|
||||
/**
|
||||
* @deprecated Use self::DOCTRINE_ORM_25 instead
|
||||
* @var string
|
||||
*/
|
||||
public const DOCTRINE_25 = self::DOCTRINE_ORM_25;
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
|
|
|
@ -3,21 +3,13 @@
|
|||
declare (strict_types=1);
|
||||
namespace Rector\Doctrine\TypeAnalyzer;
|
||||
|
||||
use PHPStan\Type\ArrayType;
|
||||
use PHPStan\Type\Generic\GenericObjectType;
|
||||
use PHPStan\Type\IntegerType;
|
||||
use PHPStan\Type\MixedType;
|
||||
use PHPStan\Type\UnionType;
|
||||
use PHPStan\Type\Type;
|
||||
use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType;
|
||||
final class CollectionTypeFactory
|
||||
{
|
||||
public function createType(FullyQualifiedObjectType $fullyQualifiedObjectType) : UnionType
|
||||
{
|
||||
$genericObjectType = $this->createGenericObjectType($fullyQualifiedObjectType);
|
||||
$arrayType = new ArrayType(new MixedType(), $fullyQualifiedObjectType);
|
||||
return new UnionType([$genericObjectType, $arrayType]);
|
||||
}
|
||||
public function createGenericObjectType(FullyQualifiedObjectType $fullyQualifiedObjectType) : GenericObjectType
|
||||
public function createType(FullyQualifiedObjectType $fullyQualifiedObjectType) : Type
|
||||
{
|
||||
$genericTypes = [new IntegerType(), $fullyQualifiedObjectType];
|
||||
return new GenericObjectType('Doctrine\\Common\\Collections\\Collection', $genericTypes);
|
||||
|
|
Loading…
Reference in New Issue
Block a user