Updated Rector to commit 7841dc582440c815796e703cf3cf9b3f17f80285

7841dc5824 Clean up usused filePath instance check on ApplicationFileProcessor (#4877)
This commit is contained in:
Tomas Votruba 2023-08-29 07:31:50 +00:00
parent 9e31017a92
commit 4650cf5c21
10 changed files with 133 additions and 17 deletions

2
vendor/autoload.php vendored
View File

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

View File

@ -1376,6 +1376,7 @@ return array(
'Rector\\Doctrine\\CodeQuality\\Rector\\Property\\CorrectDefaultTypesOnEntityPropertyRector' => $vendorDir . '/rector/rector-doctrine/rules/CodeQuality/Rector/Property/CorrectDefaultTypesOnEntityPropertyRector.php',
'Rector\\Doctrine\\CodeQuality\\Rector\\Property\\ImproveDoctrineCollectionDocTypeInEntityRector' => $vendorDir . '/rector/rector-doctrine/rules/CodeQuality/Rector/Property/ImproveDoctrineCollectionDocTypeInEntityRector.php',
'Rector\\Doctrine\\CodeQuality\\Rector\\Property\\MakeEntityDateTimePropertyDateTimeInterfaceRector' => $vendorDir . '/rector/rector-doctrine/rules/CodeQuality/Rector/Property/MakeEntityDateTimePropertyDateTimeInterfaceRector.php',
'Rector\\Doctrine\\CodeQuality\\Rector\\Property\\OrderByKeyToClassConstRector' => $vendorDir . '/rector/rector-doctrine/rules/CodeQuality/Rector/Property/OrderByKeyToClassConstRector.php',
'Rector\\Doctrine\\CodeQuality\\Rector\\Property\\TypedPropertyFromColumnTypeRector' => $vendorDir . '/rector/rector-doctrine/rules/CodeQuality/Rector/Property/TypedPropertyFromColumnTypeRector.php',
'Rector\\Doctrine\\CodeQuality\\Rector\\Property\\TypedPropertyFromDoctrineCollectionRector' => $vendorDir . '/rector/rector-doctrine/rules/CodeQuality/Rector/Property/TypedPropertyFromDoctrineCollectionRector.php',
'Rector\\Doctrine\\CodeQuality\\Rector\\Property\\TypedPropertyFromToManyRelationTypeRector' => $vendorDir . '/rector/rector-doctrine/rules/CodeQuality/Rector/Property/TypedPropertyFromToManyRelationTypeRector.php',

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInitb1d82d184156b56eb1a7dd71b46b888a
class ComposerAutoloaderInit924c364c335ca8c735536588150332cd
{
private static $loader;
@ -22,17 +22,17 @@ class ComposerAutoloaderInitb1d82d184156b56eb1a7dd71b46b888a
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInitb1d82d184156b56eb1a7dd71b46b888a', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit924c364c335ca8c735536588150332cd', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInitb1d82d184156b56eb1a7dd71b46b888a', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit924c364c335ca8c735536588150332cd', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInitb1d82d184156b56eb1a7dd71b46b888a::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit924c364c335ca8c735536588150332cd::getInitializer($loader));
$loader->setClassMapAuthoritative(true);
$loader->register(true);
$filesToLoad = \Composer\Autoload\ComposerStaticInitb1d82d184156b56eb1a7dd71b46b888a::$files;
$filesToLoad = \Composer\Autoload\ComposerStaticInit924c364c335ca8c735536588150332cd::$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 ComposerStaticInitb1d82d184156b56eb1a7dd71b46b888a
class ComposerStaticInit924c364c335ca8c735536588150332cd
{
public static $files = array (
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
@ -1596,6 +1596,7 @@ class ComposerStaticInitb1d82d184156b56eb1a7dd71b46b888a
'Rector\\Doctrine\\CodeQuality\\Rector\\Property\\CorrectDefaultTypesOnEntityPropertyRector' => __DIR__ . '/..' . '/rector/rector-doctrine/rules/CodeQuality/Rector/Property/CorrectDefaultTypesOnEntityPropertyRector.php',
'Rector\\Doctrine\\CodeQuality\\Rector\\Property\\ImproveDoctrineCollectionDocTypeInEntityRector' => __DIR__ . '/..' . '/rector/rector-doctrine/rules/CodeQuality/Rector/Property/ImproveDoctrineCollectionDocTypeInEntityRector.php',
'Rector\\Doctrine\\CodeQuality\\Rector\\Property\\MakeEntityDateTimePropertyDateTimeInterfaceRector' => __DIR__ . '/..' . '/rector/rector-doctrine/rules/CodeQuality/Rector/Property/MakeEntityDateTimePropertyDateTimeInterfaceRector.php',
'Rector\\Doctrine\\CodeQuality\\Rector\\Property\\OrderByKeyToClassConstRector' => __DIR__ . '/..' . '/rector/rector-doctrine/rules/CodeQuality/Rector/Property/OrderByKeyToClassConstRector.php',
'Rector\\Doctrine\\CodeQuality\\Rector\\Property\\TypedPropertyFromColumnTypeRector' => __DIR__ . '/..' . '/rector/rector-doctrine/rules/CodeQuality/Rector/Property/TypedPropertyFromColumnTypeRector.php',
'Rector\\Doctrine\\CodeQuality\\Rector\\Property\\TypedPropertyFromDoctrineCollectionRector' => __DIR__ . '/..' . '/rector/rector-doctrine/rules/CodeQuality/Rector/Property/TypedPropertyFromDoctrineCollectionRector.php',
'Rector\\Doctrine\\CodeQuality\\Rector\\Property\\TypedPropertyFromToManyRelationTypeRector' => __DIR__ . '/..' . '/rector/rector-doctrine/rules/CodeQuality/Rector/Property/TypedPropertyFromToManyRelationTypeRector.php',
@ -2606,9 +2607,9 @@ class ComposerStaticInitb1d82d184156b56eb1a7dd71b46b888a
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInitb1d82d184156b56eb1a7dd71b46b888a::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitb1d82d184156b56eb1a7dd71b46b888a::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitb1d82d184156b56eb1a7dd71b46b888a::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit924c364c335ca8c735536588150332cd::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit924c364c335ca8c735536588150332cd::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit924c364c335ca8c735536588150332cd::$classMap;
}, null, ClassLoader::class);
}

View File

@ -1744,12 +1744,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-doctrine.git",
"reference": "c0ab738557c373f392d488a6f5b0e9099ee9b15f"
"reference": "60b4ef14c1103d37c6b98ad9f4e64cee86194280"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-doctrine\/zipball\/c0ab738557c373f392d488a6f5b0e9099ee9b15f",
"reference": "c0ab738557c373f392d488a6f5b0e9099ee9b15f",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-doctrine\/zipball\/60b4ef14c1103d37c6b98ad9f4e64cee86194280",
"reference": "60b4ef14c1103d37c6b98ad9f4e64cee86194280",
"shasum": ""
},
"require": {
@ -1774,7 +1774,7 @@
"tomasvotruba\/type-coverage": "^0.2",
"tomasvotruba\/unused-public": "^0.1"
},
"time": "2023-08-15T22:08:55+00:00",
"time": "2023-08-29T07:28:19+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/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main c0ab738'), '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 6fbdefd'), '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 e6dd6a0'), '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 0f327da'));
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 60b4ef1'), '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 6fbdefd'), '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 e6dd6a0'), '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 0f327da'));
private function __construct()
{
}

View File

@ -12,6 +12,7 @@ use Rector\Doctrine\CodeQuality\Rector\Property\ChangeBigIntEntityPropertyToIntT
use Rector\Doctrine\CodeQuality\Rector\Property\CorrectDefaultTypesOnEntityPropertyRector;
use Rector\Doctrine\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector;
use Rector\Doctrine\CodeQuality\Rector\Property\MakeEntityDateTimePropertyDateTimeInterfaceRector;
use Rector\Doctrine\CodeQuality\Rector\Property\OrderByKeyToClassConstRector;
use Rector\Doctrine\CodeQuality\Rector\Property\TypedPropertyFromColumnTypeRector;
use Rector\Doctrine\CodeQuality\Rector\Property\TypedPropertyFromDoctrineCollectionRector;
use Rector\Doctrine\CodeQuality\Rector\Property\TypedPropertyFromToManyRelationTypeRector;
@ -33,6 +34,7 @@ return static function (RectorConfig $rectorConfig) : void {
TypedPropertyFromToOneRelationTypeRector::class,
TypedPropertyFromToManyRelationTypeRector::class,
TypedPropertyFromDoctrineCollectionRector::class,
OrderByKeyToClassConstRector::class,
]);
$rectorConfig->ruleWithConfiguration(AttributeKeyToClassConstFetchRector::class, [new AttributeKeyToClassConstFetch('Doctrine\\ORM\\Mapping\\Column', 'type', 'Doctrine\\DBAL\\Types\\Types', ['array' => 'ARRAY', 'ascii_string' => 'ASCII_STRING', 'bigint' => 'BIGINT', 'binary' => 'BINARY', 'blob' => 'BLOB', 'boolean' => 'BOOLEAN', 'date' => 'DATE_MUTABLE', 'date_immutable' => 'DATE_IMMUTABLE', 'dateinterval' => 'DATEINTERVAL', 'datetime' => 'DATETIME_MUTABLE', 'datetime_immutable' => 'DATETIME_IMMUTABLE', 'datetimetz' => 'DATETIMETZ_MUTABLE', 'datetimetz_immutable' => 'DATETIMETZ_IMMUTABLE', 'decimal' => 'DECIMAL', 'float' => 'FLOAT', 'guid' => 'GUID', 'integer' => 'INTEGER', 'json' => 'JSON', 'object' => 'OBJECT', 'simple_array' => 'SIMPLE_ARRAY', 'smallint' => 'SMALLINT', 'string' => 'STRING', 'text' => 'TEXT', 'time' => 'TIME_MUTABLE', 'time_immutable' => 'TIME_IMMUTABLE'])]);
};

View File

@ -1,4 +1,4 @@
# 14 Rules Overview
# 15 Rules Overview
## ChangeBigIntEntityPropertyToIntTypeRector
@ -217,6 +217,26 @@ Move default value for entity property to constructor, the safest place
<br>
## OrderByKeyToClassConstRector
Replace OrderBy Attribute ASC/DESC with class constant from Criteria
- class: [`Rector\Doctrine\CodeQuality\Rector\Property\OrderByKeyToClassConstRector`](../rules/CodeQuality/Rector/Property/OrderByKeyToClassConstRector.php)
```diff
use Doctrine\ORM\Mapping as ORM;
class ReplaceOrderByAscWithClassConstant
{
- #[ORM\OrderBy(['createdAt' => 'ASC'])]
+ #[ORM\OrderBy(['createdAt' => \Doctrine\Common\Collections\Criteria::ASC])]
protected \DateTimeInterface $messages;
}
?>
```
<br>
## RemoveEmptyTableAttributeRector
Remove empty Table attribute on entities because it's useless

View File

@ -0,0 +1,92 @@
<?php
declare (strict_types=1);
namespace Rector\Doctrine\CodeQuality\Rector\Property;
use RectorPrefix202308\Doctrine\Common\Collections\Criteria;
use PhpParser\Node;
use PhpParser\Node\Expr\Array_;
use PhpParser\Node\Scalar\String_;
use PhpParser\Node\Stmt\Property;
use Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode;
use Rector\Core\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
* @see \Rector\Doctrine\Tests\CodeQuality\Rector\Property\OrderByKeyToClassConstRector\OrderByKeyToClassConstRectorTest
*/
final class OrderByKeyToClassConstRector extends AbstractRector
{
public function getRuleDefinition() : RuleDefinition
{
return new RuleDefinition('Replace OrderBy Attribute ASC/DESC with class constant from Criteria', [new CodeSample(<<<'CODE_SAMPLE'
use Doctrine\ORM\Mapping as ORM;
class ReplaceOrderByAscWithClassConstant
{
#[ORM\OrderBy(['createdAt' => 'ASC'])]
protected \DateTimeInterface $messages;
}
?>
CODE_SAMPLE
, <<<'CODE_SAMPLE'
use Doctrine\ORM\Mapping as ORM;
class ReplaceOrderByAscWithClassConstant
{
#[ORM\OrderBy(['createdAt' => \Doctrine\Common\Collections\Criteria::ASC])]
protected \DateTimeInterface $messages;
}
?>
CODE_SAMPLE
)]);
}
/**
* @return array<class-string<Node>>
*/
public function getNodeTypes() : array
{
return [Property::class];
}
/**
* @param Property $node
*/
public function refactor(Node $node) : ?Node
{
$nodeAttribute = null;
foreach ($node->attrGroups as $attrGroup) {
foreach ($attrGroup->attrs as $attr) {
if ($attr->name->toString() === 'Doctrine\\ORM\\Mapping\\OrderBy') {
$nodeAttribute = $attr;
break 2;
}
}
}
// If Attribute is not OrderBy, return null
if (null === $nodeAttribute) {
return null;
}
if (!isset($nodeAttribute->args[0])) {
return null;
}
if (!$nodeAttribute->args[0]->value instanceof Array_) {
return null;
}
if (!isset($nodeAttribute->args[0]->value->items[0])) {
return null;
}
if (!$nodeAttribute->args[0]->value->items[0] instanceof Node\Expr\ArrayItem) {
return null;
}
if (!$nodeAttribute->args[0]->value->items[0]->value instanceof String_) {
return null;
}
// If Attribute value from key is not `ASC` or `DESC`, return null
if (!\in_array($nodeAttribute->args[0]->value->items[0]->value->value, ['ASC', 'asc', 'DESC', 'desc'])) {
return null;
}
$upper = \strtoupper($nodeAttribute->args[0]->value->items[0]->value->value);
$nodeAttribute->args[0]->value->items[0]->value = $this->nodeFactory->createClassConstFetch(Criteria::class, $upper);
return $node;
}
}