Updated Rector to commit b621800bef5b820ef28b3d90d670b3f644e0c808

b621800bef [Transform] Allow transform autoloadPaths() to withAutoloadPaths() on RectorConfigBuilderRector (#5630)
This commit is contained in:
Tomas Votruba 2024-02-18 00:23:41 +00:00
parent 476bd88e73
commit 30b36b6a9d
2 changed files with 11 additions and 3 deletions

View File

@ -74,6 +74,7 @@ CODE_SAMPLE
$rules = new Array_(); $rules = new Array_();
$paths = new Array_(); $paths = new Array_();
$skips = new Array_(); $skips = new Array_();
$autoloadPaths = new Array_();
foreach ($stmts as $rectorConfigStmt) { foreach ($stmts as $rectorConfigStmt) {
// complex stmts should be skipped, eg: with if else // complex stmts should be skipped, eg: with if else
if (!$rectorConfigStmt instanceof Expression) { if (!$rectorConfigStmt instanceof Expression) {
@ -95,7 +96,7 @@ CODE_SAMPLE
$name = $this->getName($rectorConfigStmt->expr->name); $name = $this->getName($rectorConfigStmt->expr->name);
if ($name === 'rule') { if ($name === 'rule') {
Assert::isAOf($rules, Array_::class); Assert::isAOf($rules, Array_::class);
$rules->items[] = new ArrayItem($rectorConfigStmt->expr->getArgs()[0]->value); $rules->items[] = new ArrayItem($value);
} elseif ($name === 'rules') { } elseif ($name === 'rules') {
if ($value instanceof Array_) { if ($value instanceof Array_) {
Assert::isAOf($rules, Array_::class); Assert::isAOf($rules, Array_::class);
@ -107,6 +108,9 @@ CODE_SAMPLE
$paths = $value; $paths = $value;
} elseif ($name === 'skip') { } elseif ($name === 'skip') {
$skips = $value; $skips = $value;
} elseif ($name === 'autoloadPaths') {
Assert::isAOf($value, Array_::class);
$autoloadPaths = $value;
} else { } else {
// implementing method by method // implementing method by method
return null; return null;
@ -124,6 +128,10 @@ CODE_SAMPLE
$newExpr = $this->nodeFactory->createMethodCall($newExpr, 'withRules', [$rules]); $newExpr = $this->nodeFactory->createMethodCall($newExpr, 'withRules', [$rules]);
$hasChanged = \true; $hasChanged = \true;
} }
if ($autoloadPaths->items !== []) {
$newExpr = $this->nodeFactory->createMethodCall($newExpr, 'withAutoloadPaths', [$autoloadPaths]);
$hasChanged = \true;
}
if ($hasChanged) { if ($hasChanged) {
$stmt->expr = $newExpr; $stmt->expr = $newExpr;
} }

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api * @api
* @var string * @var string
*/ */
public const PACKAGE_VERSION = 'a533e70fca40571ab9504fbb857205b2be2eccb6'; public const PACKAGE_VERSION = 'b621800bef5b820ef28b3d90d670b3f644e0c808';
/** /**
* @api * @api
* @var string * @var string
*/ */
public const RELEASE_DATE = '2024-02-17 11:56:55'; public const RELEASE_DATE = '2024-02-18 07:21:31';
/** /**
* @var int * @var int
*/ */