Updated Rector to commit c00475c746d1cff33dafb21e8d51815a0b711efc

c00475c746 Update phpdoc-parser to ^1.20.3 (#3691)
This commit is contained in:
Tomas Votruba 2023-04-27 11:55:52 +00:00
parent 62693051ca
commit bc397e417b
12 changed files with 164 additions and 22 deletions

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '31e22ff70699ac52c0cd4faee5b5f42291bb8ccb';
public const PACKAGE_VERSION = 'c00475c746d1cff33dafb21e8d51815a0b711efc';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2023-04-26 20:29:58';
public const RELEASE_DATE = '2023-04-27 11:51:55';
/**
* @var int
*/

2
vendor/autoload.php vendored
View File

@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) {
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit1059b3a7b4881f801c4e30b8ee7d67d7::getLoader();
return ComposerAutoloaderInitdc2bc17d1ebedac65d874213cdea182d::getLoader();

View File

@ -1718,6 +1718,7 @@ return array(
'Rector\\Doctrine\\Rector\\MethodCall\\ChangeSetParametersArrayToArrayCollectionRector' => $vendorDir . '/rector/rector-doctrine/src/Rector/MethodCall/ChangeSetParametersArrayToArrayCollectionRector.php',
'Rector\\Doctrine\\Rector\\MethodCall\\EntityAliasToClassConstantReferenceRector' => $vendorDir . '/rector/rector-doctrine/src/Rector/MethodCall/EntityAliasToClassConstantReferenceRector.php',
'Rector\\Doctrine\\Rector\\MethodCall\\ReplaceParentRepositoryCallsByRepositoryPropertyRector' => $vendorDir . '/rector/rector-doctrine/src/Rector/MethodCall/ReplaceParentRepositoryCallsByRepositoryPropertyRector.php',
'Rector\\Doctrine\\Rector\\Param\\ReplaceLifecycleEventArgsByDedicatedEventArgsRector' => $vendorDir . '/rector/rector-doctrine/src/Rector/Param/ReplaceLifecycleEventArgsByDedicatedEventArgsRector.php',
'Rector\\Doctrine\\Rector\\Property\\ChangeBigIntEntityPropertyToIntTypeRector' => $vendorDir . '/rector/rector-doctrine/src/Rector/Property/ChangeBigIntEntityPropertyToIntTypeRector.php',
'Rector\\Doctrine\\Rector\\Property\\CorrectDefaultTypesOnEntityPropertyRector' => $vendorDir . '/rector/rector-doctrine/src/Rector/Property/CorrectDefaultTypesOnEntityPropertyRector.php',
'Rector\\Doctrine\\Rector\\Property\\DoctrineTargetEntityStringToClassConstantRector' => $vendorDir . '/rector/rector-doctrine/src/Rector/Property/DoctrineTargetEntityStringToClassConstantRector.php',

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit1059b3a7b4881f801c4e30b8ee7d67d7
class ComposerAutoloaderInitdc2bc17d1ebedac65d874213cdea182d
{
private static $loader;
@ -22,17 +22,17 @@ class ComposerAutoloaderInit1059b3a7b4881f801c4e30b8ee7d67d7
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit1059b3a7b4881f801c4e30b8ee7d67d7', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInitdc2bc17d1ebedac65d874213cdea182d', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInit1059b3a7b4881f801c4e30b8ee7d67d7', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInitdc2bc17d1ebedac65d874213cdea182d', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit1059b3a7b4881f801c4e30b8ee7d67d7::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInitdc2bc17d1ebedac65d874213cdea182d::getInitializer($loader));
$loader->setClassMapAuthoritative(true);
$loader->register(true);
$filesToLoad = \Composer\Autoload\ComposerStaticInit1059b3a7b4881f801c4e30b8ee7d67d7::$files;
$filesToLoad = \Composer\Autoload\ComposerStaticInitdc2bc17d1ebedac65d874213cdea182d::$files;
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;

View File

@ -4,7 +4,7 @@
namespace Composer\Autoload;
class ComposerStaticInit1059b3a7b4881f801c4e30b8ee7d67d7
class ComposerStaticInitdc2bc17d1ebedac65d874213cdea182d
{
public static $files = array (
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
@ -1965,6 +1965,7 @@ class ComposerStaticInit1059b3a7b4881f801c4e30b8ee7d67d7
'Rector\\Doctrine\\Rector\\MethodCall\\ChangeSetParametersArrayToArrayCollectionRector' => __DIR__ . '/..' . '/rector/rector-doctrine/src/Rector/MethodCall/ChangeSetParametersArrayToArrayCollectionRector.php',
'Rector\\Doctrine\\Rector\\MethodCall\\EntityAliasToClassConstantReferenceRector' => __DIR__ . '/..' . '/rector/rector-doctrine/src/Rector/MethodCall/EntityAliasToClassConstantReferenceRector.php',
'Rector\\Doctrine\\Rector\\MethodCall\\ReplaceParentRepositoryCallsByRepositoryPropertyRector' => __DIR__ . '/..' . '/rector/rector-doctrine/src/Rector/MethodCall/ReplaceParentRepositoryCallsByRepositoryPropertyRector.php',
'Rector\\Doctrine\\Rector\\Param\\ReplaceLifecycleEventArgsByDedicatedEventArgsRector' => __DIR__ . '/..' . '/rector/rector-doctrine/src/Rector/Param/ReplaceLifecycleEventArgsByDedicatedEventArgsRector.php',
'Rector\\Doctrine\\Rector\\Property\\ChangeBigIntEntityPropertyToIntTypeRector' => __DIR__ . '/..' . '/rector/rector-doctrine/src/Rector/Property/ChangeBigIntEntityPropertyToIntTypeRector.php',
'Rector\\Doctrine\\Rector\\Property\\CorrectDefaultTypesOnEntityPropertyRector' => __DIR__ . '/..' . '/rector/rector-doctrine/src/Rector/Property/CorrectDefaultTypesOnEntityPropertyRector.php',
'Rector\\Doctrine\\Rector\\Property\\DoctrineTargetEntityStringToClassConstantRector' => __DIR__ . '/..' . '/rector/rector-doctrine/src/Rector/Property/DoctrineTargetEntityStringToClassConstantRector.php',
@ -3150,9 +3151,9 @@ class ComposerStaticInit1059b3a7b4881f801c4e30b8ee7d67d7
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit1059b3a7b4881f801c4e30b8ee7d67d7::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit1059b3a7b4881f801c4e30b8ee7d67d7::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit1059b3a7b4881f801c4e30b8ee7d67d7::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInitdc2bc17d1ebedac65d874213cdea182d::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitdc2bc17d1ebedac65d874213cdea182d::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitdc2bc17d1ebedac65d874213cdea182d::$classMap;
}, null, ClassLoader::class);
}

View File

@ -1919,12 +1919,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-doctrine.git",
"reference": "040c091692d6a455363cbb2a61435d5dfd1477d0"
"reference": "03df9e339b005534311b732c616a5d0a9e23158a"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-doctrine\/zipball\/040c091692d6a455363cbb2a61435d5dfd1477d0",
"reference": "040c091692d6a455363cbb2a61435d5dfd1477d0",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-doctrine\/zipball\/03df9e339b005534311b732c616a5d0a9e23158a",
"reference": "03df9e339b005534311b732c616a5d0a9e23158a",
"shasum": ""
},
"require": {
@ -1951,7 +1951,7 @@
"symplify\/rule-doc-generator": "^11.1",
"symplify\/vendor-patches": "^11.1"
},
"time": "2023-04-17T15:34:51+00:00",
"time": "2023-04-27T07:31:23+00:00",
"default-branch": true,
"type": "rector-extension",
"extra": {
@ -1978,7 +1978,7 @@
"description": "Rector upgrades rules for Doctrine",
"support": {
"issues": "https:\/\/github.com\/rectorphp\/rector-doctrine\/issues",
"source": "https:\/\/github.com\/rectorphp\/rector-doctrine\/tree\/0.14.2"
"source": "https:\/\/github.com\/rectorphp\/rector-doctrine\/tree\/main"
},
"install-path": "..\/rector\/rector-doctrine"
},

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/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 040c091'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 23e55c6'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main dc4b405'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 11347bc'));
public const EXTENSIONS = array('rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 03df9e3'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 23e55c6'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main dc4b405'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 11347bc'));
private function __construct()
{
}

View File

@ -0,0 +1,10 @@
<?php
declare (strict_types=1);
namespace RectorPrefix202304;
use Rector\Config\RectorConfig;
use Rector\Doctrine\Rector\Param\ReplaceLifecycleEventArgsByDedicatedEventArgsRector;
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->rule(ReplaceLifecycleEventArgsByDedicatedEventArgsRector::class);
};

View File

@ -1,4 +1,4 @@
# 24 Rules Overview
# 26 Rules Overview
## AddEntityIdByConditionRector
@ -17,7 +17,12 @@ use Rector\Config\RectorConfig;
use Rector\Doctrine\Rector\Class_\AddEntityIdByConditionRector;
return static function (RectorConfig $rectorConfig): void {
$rectorConfig->ruleWithConfiguration(AddEntityIdByConditionRector::class, [AddEntityIdByConditionRector::DETECTED_TRAITS => ['Knp\DoctrineBehaviors\Model\Translatable\Translation', 'Knp\DoctrineBehaviors\Model\Translatable\TranslationTrait']]);
$rectorConfig->ruleWithConfiguration(AddEntityIdByConditionRector::class, [
AddEntityIdByConditionRector::DETECTED_TRAITS => [
'Knp\DoctrineBehaviors\Model\Translatable\Translation',
'Knp\DoctrineBehaviors\Model\Translatable\TranslationTrait',
],
]);
};
```
@ -223,7 +228,11 @@ use Rector\Config\RectorConfig;
use Rector\Doctrine\Rector\MethodCall\EntityAliasToClassConstantReferenceRector;
return static function (RectorConfig $rectorConfig): void {
$rectorConfig->ruleWithConfiguration(EntityAliasToClassConstantReferenceRector::class, [EntityAliasToClassConstantReferenceRector::ALIASES_TO_NAMESPACES => ['App' => 'App\Entity']]);
$rectorConfig->ruleWithConfiguration(EntityAliasToClassConstantReferenceRector::class, [
EntityAliasToClassConstantReferenceRector::ALIASES_TO_NAMESPACES => [
'App' => 'App\Entity',
],
]);
};
```
@ -449,6 +458,24 @@ Turns parent EntityRepository class to constructor dependency
<br>
## RemoveEmptyTableAttributeRector
Remove empty Table attribute on entities because it's useless
- class: [`Rector\Doctrine\Rector\Class_\RemoveEmptyTableAttributeRector`](../src/Rector/Class_/RemoveEmptyTableAttributeRector.php)
```diff
use Doctrine\ORM\Mapping as ORM;
-#[ORM\Table]
#[ORM\Entity]
class Product
{
}
```
<br>
## RemoveRedundantDefaultClassAnnotationValuesRector
Removes redundant default values from Doctrine ORM annotations on class level
@ -514,6 +541,28 @@ Removes repository class from `@Entity` annotation
<br>
## ReplaceLifecycleEventArgsByDedicatedEventArgsRector
Replace `Doctrine\ORM\Event\LifecycleEventArgs` with specific event classes based on the function call
- class: [`Rector\Doctrine\Rector\Param\ReplaceLifecycleEventArgsByDedicatedEventArgsRector`](../src/Rector/Param/ReplaceLifecycleEventArgsByDedicatedEventArgsRector.php)
```diff
-use Doctrine\ORM\Event\LifecycleEventArgs;
+use Doctrine\ORM\Event\PrePersistEventArgs;
class PrePersistExample
{
- public function prePersist(LifecycleEventArgs $args)
+ public function prePersist(PrePersistEventArgs $args)
{
// ...
}
}
```
<br>
## ReplaceParentRepositoryCallsByRepositoryPropertyRector
Handles method calls in child of Doctrine EntityRepository and moves them to `$this->repository` property.

View File

@ -0,0 +1,77 @@
<?php
declare (strict_types=1);
namespace Rector\Doctrine\Rector\Param;
use PhpParser\Node;
use PhpParser\Node\Name\FullyQualified;
use PhpParser\Node\Stmt\ClassMethod;
use PHPStan\Type\ObjectType;
use Rector\Core\Rector\AbstractRector;
use Rector\NodeTypeResolver\Node\AttributeKey;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
* @see https://github.com/doctrine/orm/pull/10086
* @see \Rector\Doctrine\Tests\Rector\Param\ReplaceLifecycleEventArgsByDedicatedEventArgsRector\ReplaceLifecycleEventArgsByDedicatedEventArgsRectorTest
*/
final class ReplaceLifecycleEventArgsByDedicatedEventArgsRector extends AbstractRector
{
private const EVENT_CLASSES = ['prePersist' => 'Doctrine\\ORM\\Event\\PrePersistEventArgs', 'preUpdate' => 'Doctrine\\ORM\\Event\\PreUpdateEventArgs', 'preRemove' => 'Doctrine\\ORM\\Event\\PreRemoveEventArgs', 'postPersist' => 'Doctrine\\ORM\\Event\\PostPersistEventArgs', 'postUpdate' => 'Doctrine\\ORM\\Event\\PostUpdateEventArgs', 'postRemove' => 'Doctrine\\ORM\\Event\\PostRemoveEventArgs', 'postLoad' => 'Doctrine\\ORM\\Event\\PostLoadEventArgs'];
public function getRuleDefinition() : RuleDefinition
{
return new RuleDefinition('Replace Doctrine\\ORM\\Event\\LifecycleEventArgs with specific event classes based on the function call', [new CodeSample(<<<'CODE_SAMPLE'
use Doctrine\ORM\Event\LifecycleEventArgs;
class PrePersistExample
{
public function prePersist(LifecycleEventArgs $args)
{
// ...
}
}
CODE_SAMPLE
, <<<'CODE_SAMPLE'
use Doctrine\ORM\Event\PrePersistEventArgs;
class PrePersistExample
{
public function prePersist(PrePersistEventArgs $args)
{
// ...
}
}
CODE_SAMPLE
)]);
}
/**
* @return array<class-string<Node\Param>>
*/
public function getNodeTypes() : array
{
return [Node\Param::class];
}
/**
* @param Node\Param $node
*/
public function refactor(Node $node) : ?Node
{
if (!$this->isObjectType($node, new ObjectType('Doctrine\\ORM\\Event\\LifecycleEventArgs'))) {
return null;
}
if ($this->isObjectType($node, new ObjectType('Doctrine\\ORM\\Event\\PrePersistEventArgs')) || $this->isObjectType($node, new ObjectType('Doctrine\\ORM\\Event\\PreUpdateEventArgs')) || $this->isObjectType($node, new ObjectType('Doctrine\\ORM\\Event\\PreRemoveEventArgs')) || $this->isObjectType($node, new ObjectType('Doctrine\\ORM\\Event\\PostPersistEventArgs')) || $this->isObjectType($node, new ObjectType('Doctrine\\ORM\\Event\\PostUpdateEventArgs')) || $this->isObjectType($node, new ObjectType('Doctrine\\ORM\\Event\\PostRemoveEventArgs')) || $this->isObjectType($node, new ObjectType('Doctrine\\ORM\\Event\\PostLoadEventArgs'))) {
return null;
}
$classMethod = $node->getAttribute(AttributeKey::PARENT_NODE);
if (!$classMethod instanceof ClassMethod) {
return null;
}
$eventClass = self::EVENT_CLASSES[$classMethod->name->name] ?? null;
if ($eventClass === null) {
return null;
}
$node->type = new FullyQualified($eventClass);
return $node;
}
}

View File

@ -53,6 +53,10 @@ final class DoctrineSetList implements SetListInterface
* @var string
*/
public const DOCTRINE_ORM_213 = __DIR__ . '/../../config/sets/doctrine-orm-213.php';
/**
* @var string
*/
public const DOCTRINE_ORM_214 = __DIR__ . '/../../config/sets/doctrine-orm-214.php';
/**
* @var string
*/