Updated Rector to commit 6bff51172cf396da8abc062d96f0406fd86ef349

6bff51172c [e2e] Add e2e for polyfill in composer require provided (#5392)
This commit is contained in:
Tomas Votruba 2023-12-26 12:13:04 +00:00
parent 24ab7232bb
commit a8c5484976
8 changed files with 111 additions and 7 deletions

View File

@ -1392,6 +1392,7 @@ return array(
'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',
'Rector\\Doctrine\\CodeQuality\\Rector\\Property\\TypedPropertyFromToOneRelationTypeRector' => $vendorDir . '/rector/rector-doctrine/rules/CodeQuality/Rector/Property/TypedPropertyFromToOneRelationTypeRector.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',

View File

@ -1610,6 +1610,7 @@ class ComposerStaticInit8339caf294dd12447c06647e5d0dc118
'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',
'Rector\\Doctrine\\CodeQuality\\Rector\\Property\\TypedPropertyFromToOneRelationTypeRector' => __DIR__ . '/..' . '/rector/rector-doctrine/rules/CodeQuality/Rector/Property/TypedPropertyFromToOneRelationTypeRector.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',

View File

@ -1679,12 +1679,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-doctrine.git",
"reference": "18273edb4e165d60503c403e72f9824ac204d653"
"reference": "7e78350590f0b22c11a8ef90d7c1e35aa22d2424"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-doctrine\/zipball\/18273edb4e165d60503c403e72f9824ac204d653",
"reference": "18273edb4e165d60503c403e72f9824ac204d653",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-doctrine\/zipball\/7e78350590f0b22c11a8ef90d7c1e35aa22d2424",
"reference": "7e78350590f0b22c11a8ef90d7c1e35aa22d2424",
"shasum": ""
},
"require": {
@ -1709,7 +1709,7 @@
"tomasvotruba\/unused-public": "^0.3",
"tracy\/tracy": "^2.10"
},
"time": "2023-12-25T13:32:36+00:00",
"time": "2023-12-26T12:08:25+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 18273ed'), '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 1cbcfcb'), '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 5f1e96d'));
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 7e78350'), '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 1cbcfcb'), '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 5f1e96d'));
private function __construct()
{
}

View File

@ -4,6 +4,7 @@ declare (strict_types=1);
namespace RectorPrefix202312;
use Rector\Config\RectorConfig;
use Rector\Doctrine\Dbal211\Rector\MethodCall\ExtractArrayArgOnQueryBuilderSelectRector;
use Rector\Renaming\Rector\ClassConstFetch\RenameClassConstFetchRector;
use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
use Rector\Renaming\Rector\Name\RenameClassRector;
@ -62,4 +63,7 @@ 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);
};

View File

@ -1,4 +1,4 @@
# 16 Rules Overview
# 17 Rules Overview
## ChangeCompositeExpressionAddMultipleWithWithRector
@ -87,6 +87,22 @@ Replace EventSubscriberInterface with AsDoctrineListener attribute(s)
<br>
## ExtractArrayArgOnQueryBuilderSelectRector
Extract array arg on QueryBuilder select, addSelect, groupBy, addGroupBy
- class: [`Rector\Doctrine\Dbal211\Rector\MethodCall\ExtractArrayArgOnQueryBuilderSelectRector`](../rules/Dbal211/Rector/MethodCall/ExtractArrayArgOnQueryBuilderSelectRector.php)
```diff
function query(\Doctrine\DBAL\Query\QueryBuilder $queryBuilder)
{
- $query = $queryBuilder->select(['u.id', 'p.id']);
+ $query = $queryBuilder->select('u.id', 'p.id');
}
```
<br>
## ImproveDoctrineCollectionDocTypeInEntityRector
Improve @var, `@param` and `@return` types for Doctrine collections to make them useful both for PHPStan and PHPStorm

View File

@ -0,0 +1,82 @@
<?php
declare (strict_types=1);
namespace Rector\Doctrine\Dbal211\Rector\MethodCall;
use PhpParser\Node;
use PhpParser\Node\Arg;
use PhpParser\Node\Expr\Array_;
use PhpParser\Node\Expr\ArrayItem;
use PhpParser\Node\Expr\MethodCall;
use PHPStan\Type\ObjectType;
use Rector\Core\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
* @changelog https://github.com/doctrine/dbal/pull/3853
* @changelog https://github.com/doctrine/dbal/issues/3837
*
* @see \Rector\Doctrine\Tests\Dbal211\Rector\MethodCall\ExtractArrayArgOnQueryBuilderSelectRector\ExtractArrayArgOnQueryBuilderSelectRectorTest
*/
final class ExtractArrayArgOnQueryBuilderSelectRector extends AbstractRector
{
/**
* @return array<class-string<Node>>
*/
public function getNodeTypes() : array
{
return [MethodCall::class];
}
public function getRuleDefinition() : RuleDefinition
{
return new RuleDefinition('Extract array arg on QueryBuilder select, addSelect, groupBy, addGroupBy', [new CodeSample(<<<'CODE_SAMPLE'
function query(\Doctrine\DBAL\Query\QueryBuilder $queryBuilder)
{
$query = $queryBuilder->select(['u.id', 'p.id']);
}
CODE_SAMPLE
, <<<'CODE_SAMPLE'
function query(\Doctrine\DBAL\Query\QueryBuilder $queryBuilder)
{
$query = $queryBuilder->select('u.id', 'p.id');
}
CODE_SAMPLE
)]);
}
/**
* @param MethodCall $node
*/
public function refactor(Node $node) : ?MethodCall
{
$varType = $this->nodeTypeResolver->getType($node->var);
if (!$varType instanceof ObjectType) {
return null;
}
if (!$varType->isInstanceOf('Doctrine\\DBAL\\Query\\QueryBuilder')->yes()) {
return null;
}
if (!$this->isNames($node->name, ['select', 'addSelect', 'groupBy', 'addGroupBy'])) {
return null;
}
if ($node->isFirstClassCallable()) {
return null;
}
$args = $node->getArgs();
if (\count($args) !== 1) {
return null;
}
$currentArg = $args[0]->value;
if (!$currentArg instanceof Array_) {
return null;
}
$newArgs = [];
foreach ($currentArg->items as $value) {
if (!$value instanceof ArrayItem) {
return null;
}
$newArgs[] = new Arg($value);
}
$node->args = $newArgs;
return $node;
}
}