Updated Rector to commit 76504227a46a540c8736759103478db2459ec5ca

76504227a4 Clean up parallel-lint exclude on downgrade build (#5590)
This commit is contained in:
Tomas Votruba 2024-02-09 11:42:47 +00:00
parent a0a66ea1c7
commit 5d5a36456b
11 changed files with 181 additions and 62 deletions

View File

@ -1316,6 +1316,7 @@ return array(
'Rector\\Doctrine\\CodeQuality\\Utils\\CaseStringHelper' => $vendorDir . '/rector/rector-doctrine/rules/CodeQuality/Utils/CaseStringHelper.php',
'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\\Dbal211\\Rector\\MethodCall\\ReplaceFetchAllMethodCallRector' => $vendorDir . '/rector/rector-doctrine/rules/Dbal211/Rector/MethodCall/ReplaceFetchAllMethodCallRector.php',
'Rector\\Doctrine\\Dbal40\\Rector\\MethodCall\\ChangeCompositeExpressionAddMultipleWithWithRector' => $vendorDir . '/rector/rector-doctrine/rules/Dbal40/Rector/MethodCall/ChangeCompositeExpressionAddMultipleWithWithRector.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',

View File

@ -1530,6 +1530,7 @@ class ComposerStaticInit2d887a2f87c676eb32b3e04612865e54
'Rector\\Doctrine\\CodeQuality\\Utils\\CaseStringHelper' => __DIR__ . '/..' . '/rector/rector-doctrine/rules/CodeQuality/Utils/CaseStringHelper.php',
'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\\Dbal211\\Rector\\MethodCall\\ReplaceFetchAllMethodCallRector' => __DIR__ . '/..' . '/rector/rector-doctrine/rules/Dbal211/Rector/MethodCall/ReplaceFetchAllMethodCallRector.php',
'Rector\\Doctrine\\Dbal40\\Rector\\MethodCall\\ChangeCompositeExpressionAddMultipleWithWithRector' => __DIR__ . '/..' . '/rector/rector-doctrine/rules/Dbal40/Rector/MethodCall/ChangeCompositeExpressionAddMultipleWithWithRector.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',

View File

@ -1679,37 +1679,35 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-doctrine.git",
"reference": "f6b9b1d46b66091f5a2c22b9bcc2ba035a4274be"
"reference": "981048a16974f8b38916ba3b4e028c0388543585"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-doctrine\/zipball\/f6b9b1d46b66091f5a2c22b9bcc2ba035a4274be",
"reference": "f6b9b1d46b66091f5a2c22b9bcc2ba035a4274be",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-doctrine\/zipball\/981048a16974f8b38916ba3b4e028c0388543585",
"reference": "981048a16974f8b38916ba3b4e028c0388543585",
"shasum": ""
},
"require": {
"php": ">=8.1"
"php": ">=8.2"
},
"require-dev": {
"doctrine\/orm": "^2.16",
"doctrine\/orm": "^2.18",
"phpstan\/extension-installer": "^1.3",
"phpstan\/phpstan": "^1.10",
"phpstan\/phpstan": "^1.10.57",
"phpstan\/phpstan-webmozart-assert": "^1.2",
"phpunit\/phpunit": "^10.3",
"rector\/phpstan-rules": "^0.7",
"rector\/rector-generator": "^0.7.5",
"phpunit\/phpunit": "^10.5",
"rector\/rector-generator": "^0.7.10",
"rector\/rector-src": "dev-main",
"symplify\/easy-coding-standard": "^12.0",
"symplify\/phpstan-extensions": "^11.2",
"symplify\/phpstan-rules": "^11.1",
"symplify\/rule-doc-generator": "^12.0",
"symplify\/vendor-patches": "^11.2",
"tomasvotruba\/class-leak": "^0.2",
"tomasvotruba\/type-coverage": "^0.2",
"symplify\/easy-coding-standard": "^12.1",
"symplify\/phpstan-extensions": "^11.4",
"symplify\/phpstan-rules": "^11.4",
"symplify\/rule-doc-generator": "^12.1",
"symplify\/vendor-patches": "^11.3",
"tomasvotruba\/class-leak": "^0.2.8",
"tomasvotruba\/unused-public": "^0.3",
"tracy\/tracy": "^2.10"
},
"time": "2024-01-31T09:34:50+00:00",
"time": "2024-02-09T11:39:24+00:00",
"default-branch": true,
"type": "rector-extension",
"extra": {

File diff suppressed because one or more lines are too long

View File

@ -9,7 +9,7 @@ namespace Rector\RectorInstaller;
*/
final class GeneratedConfig
{
public const EXTENSIONS = array('rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => NULL, 'version' => 'dev-main f6b9b1d'), '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 f091938'), '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 92f8dec'));
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 981048a'), '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 f091938'), '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 92f8dec'));
private function __construct()
{
}

View File

@ -4,25 +4,23 @@
"license": "MIT",
"description": "Rector upgrades rules for Doctrine",
"require": {
"php": ">=8.1"
"php": ">=8.2"
},
"require-dev": {
"doctrine\/orm": "^2.18",
"phpstan\/extension-installer": "^1.3",
"rector\/phpstan-rules": "^0.7",
"phpstan\/phpstan": "^1.10",
"phpunit\/phpunit": "^10.3",
"symplify\/phpstan-rules": "^11.1",
"symplify\/phpstan-extensions": "^11.2",
"symplify\/easy-coding-standard": "^12.0",
"symplify\/rule-doc-generator": "^12.0",
"rector\/rector-src": "dev-main",
"doctrine\/orm": "^2.16",
"phpstan\/phpstan-webmozart-assert": "^1.2",
"symplify\/vendor-patches": "^11.2",
"rector\/rector-generator": "^0.7.5",
"phpstan\/phpstan": "^1.10.57",
"phpunit\/phpunit": "^10.5",
"rector\/rector-src": "dev-main",
"symplify\/phpstan-rules": "^11.4",
"symplify\/phpstan-extensions": "^11.4",
"symplify\/easy-coding-standard": "^12.1",
"symplify\/rule-doc-generator": "^12.1",
"symplify\/vendor-patches": "^11.3",
"rector\/rector-generator": "^0.7.10",
"tomasvotruba\/unused-public": "^0.3",
"tomasvotruba\/type-coverage": "^0.2",
"tomasvotruba\/class-leak": "^0.2",
"tomasvotruba\/class-leak": "^0.2.8",
"tracy\/tracy": "^2.10"
},
"autoload": {
@ -61,6 +59,7 @@
"minimum-stability": "dev",
"prefer-stable": true,
"config": {
"sort-packages": true,
"allow-plugins": {
"cweagans\/composer-patches": true,
"rector\/extension-installer": true,

View File

@ -5,6 +5,7 @@ namespace RectorPrefix202402;
use Rector\Config\RectorConfig;
use Rector\Doctrine\Dbal211\Rector\MethodCall\ExtractArrayArgOnQueryBuilderSelectRector;
use Rector\Doctrine\Dbal211\Rector\MethodCall\ReplaceFetchAllMethodCallRector;
use Rector\Renaming\Rector\ClassConstFetch\RenameClassConstFetchRector;
use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
use Rector\Renaming\Rector\Name\RenameClassRector;
@ -63,7 +64,10 @@ return static function (RectorConfig $rectorConfig) : void {
// https://github.com/doctrine/dbal/blob/master/UPGRADE.md#deprecated-masterslaveconnection-use-primaryreadreplicaconnection
'Doctrine\\DBAL\\Connections\\MasterSlaveConnection' => 'Doctrine\\DBAL\\Connections\\PrimaryReadReplicaConnection',
]);
# https://github.com/doctrine/dbal/pull/3853
# https://github.com/doctrine/dbal/issues/3837
$rectorConfig->rule(ExtractArrayArgOnQueryBuilderSelectRector::class);
$rectorConfig->rules([
// https://github.com/doctrine/dbal/pull/3853
// https://github.com/doctrine/dbal/issues/3837
ExtractArrayArgOnQueryBuilderSelectRector::class,
ReplaceFetchAllMethodCallRector::class,
]);
};

View File

@ -1,4 +1,4 @@
# 17 Rules Overview
# 18 Rules Overview
## ChangeCompositeExpressionAddMultipleWithWithRector
@ -284,6 +284,27 @@ Remove empty Table attribute on entities because it's useless
<br>
## ReplaceFetchAllMethodCallRector
Change `Doctrine\DBAL\Connection` `->fetchAll()` to `->fetchAllAssociative()` and other replacements
- class: [`Rector\Doctrine\Dbal211\Rector\MethodCall\ReplaceFetchAllMethodCallRector`](../rules/Dbal211/Rector/MethodCall/ReplaceFetchAllMethodCallRector.php)
```diff
use Doctrine\DBAL\Connection;
class SomeClass
{
public function run(Connection $connection)
{
- return $connection->fetchAll();
+ return $connection->fetchAllAssociative();
}
}
```
<br>
## ReplaceLifecycleEventArgsByDedicatedEventArgsRector
Replace `Doctrine\ORM\Event\LifecycleEventArgs` with specific event classes based on the function call

View File

@ -1,10 +0,0 @@
<?php
declare (strict_types=1);
namespace RectorPrefix202402;
use RectorPrefix202402\Symplify\EasyCI\Config\EasyCIConfig;
return static function (EasyCIConfig $easyCIConfig) : void {
$easyCIConfig->paths([__DIR__ . '/config', __DIR__ . '/src', __DIR__ . '/rules']);
$easyCIConfig->typesToSkip([\Rector\Contract\Rector\RectorInterface::class]);
};

View File

@ -5,18 +5,4 @@ namespace RectorPrefix202402;
use Rector\Config\RectorConfig;
use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector;
use Rector\PHPUnit\Set\PHPUnitSetList;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Set\ValueObject\SetList;
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->importNames();
$rectorConfig->removeUnusedImports();
$rectorConfig->paths([__DIR__ . '/src', __DIR__ . '/rules', __DIR__ . '/tests']);
$rectorConfig->skip([
// for tests
'*/Source/*',
'*/Fixture/*',
]);
$rectorConfig->sets([LevelSetList::UP_TO_PHP_81, PHPUnitSetList::PHPUNIT_100, SetList::DEAD_CODE, SetList::CODE_QUALITY, SetList::CODING_STYLE, SetList::NAMING, SetList::TYPE_DECLARATION, SetList::PRIVATIZATION]);
$rectorConfig->ruleWithConfiguration(StringClassNameToClassConstantRector::class, ['Doctrine\\*', 'Gedmo\\*', 'Knp\\*', 'DateTime', 'DateTimeInterface']);
};
return RectorConfig::configure()->withImportNames(\true, \true, \true, \true)->withPaths([__DIR__ . '/src', __DIR__ . '/rules', __DIR__ . '/tests'])->withSkip(['*/Source/*', '*/Fixture/*'])->withRootFiles()->withPhpSets()->withPreparedSets(\true, \true, \true, \true, \true, \true)->withConfiguredRule(StringClassNameToClassConstantRector::class, ['Doctrine\\*', 'Gedmo\\*', 'Knp\\*', 'DateTime', 'DateTimeInterface']);

View File

@ -0,0 +1,119 @@
<?php
declare (strict_types=1);
namespace Rector\Doctrine\Dbal211\Rector\MethodCall;
use PhpParser\Node;
use PhpParser\Node\Arg;
use PhpParser\Node\Expr\ClassConstFetch;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Identifier;
use PHPStan\Type\ObjectType;
use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
* @see \Rector\Doctrine\Tests\Dbal211\Rector\MethodCall\ReplaceFetchAllMethodCallRector\ReplaceFetchAllMethodCallRectorTest
*
* @changelog https://github.com/doctrine/dbal/pull/4019
*/
final class ReplaceFetchAllMethodCallRector extends AbstractRector
{
public function getRuleDefinition() : RuleDefinition
{
return new RuleDefinition('Change Doctrine\\DBAL\\Connection and Doctrine\\DBAL\\Driver\\ResultStatement ->fetchAll() to ->fetchAllAssociative() and other replacements', [new CodeSample(<<<'CODE_SAMPLE'
use Doctrine\DBAL\Connection;
class SomeClass
{
public function run(Connection $connection)
{
return $connection->fetchAll();
}
}
CODE_SAMPLE
, <<<'CODE_SAMPLE'
use Doctrine\DBAL\Connection;
class SomeClass
{
public function run(Connection $connection)
{
return $connection->fetchAllAssociative();
}
}
CODE_SAMPLE
)]);
}
/**
* @return array<class-string<Node>>
*/
public function getNodeTypes() : array
{
return [MethodCall::class];
}
/**
* @param MethodCall $node
*/
public function refactor(Node $node) : ?Node
{
if ($this->isObjectType($node->var, new ObjectType('Doctrine\\DBAL\\Connection'))) {
return $this->refactorConnection($node);
}
if ($this->isObjectType($node->var, new ObjectType('Doctrine\\DBAL\\Driver\\ResultStatement'))) {
return $this->refactorResultStatement($node);
}
return null;
}
private function refactorConnection(MethodCall $methodCall) : ?\PhpParser\Node\Expr\MethodCall
{
if ($this->isName($methodCall->name, 'fetchAll')) {
$methodCall->name = new Identifier('fetchAllAssociative');
return $methodCall;
}
if ($this->isName($methodCall->name, 'fetchArray')) {
$methodCall->name = new Identifier('fetchNumeric');
return $methodCall;
}
return null;
}
private function refactorResultStatement(MethodCall $methodCall) : ?\PhpParser\Node\Expr\MethodCall
{
if ($this->isName($methodCall->name, 'fetchColumn')) {
$methodCall->name = new Identifier('fetchOne');
return $methodCall;
}
if ($this->isName($methodCall->name, 'fetchAll')) {
$args = $methodCall->getArgs();
if ($args === []) {
// not sure yet
return null;
}
$firstArg = $args[0];
$newMethodName = $this->resolveFirstMethodName($firstArg);
if (\is_string($newMethodName)) {
$methodCall->args = [];
$methodCall->name = new Identifier($newMethodName);
return $methodCall;
}
}
return null;
}
private function resolveFirstMethodName(Arg $firstArg) : ?string
{
if (!$firstArg->value instanceof ClassConstFetch) {
return null;
}
$classConstFetch = $firstArg->value;
if (!$this->isName($classConstFetch->class, 'PDO')) {
return null;
}
if ($this->isName($classConstFetch->name, 'FETCH_COLUMN')) {
return 'fetchFirstColumn';
}
if ($this->isName($classConstFetch->name, 'FETCH_ASSOC')) {
return 'fetchAllAssociative';
}
return null;
}
}