Skip to content

Commit

Permalink
Updated Rector to commit 5e5681d9edbb438b5782b45fde6e88650aa3843f
Browse files Browse the repository at this point in the history
rectorphp/rector-src@5e5681d [NodeRemover] Use return null after ->removeNode() (#3558)
  • Loading branch information
TomasVotruba committed Apr 3, 2023
1 parent 123448a commit f5640c1
Show file tree
Hide file tree
Showing 13 changed files with 23 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public function refactor(Node $node) : ?Node
return $this->cleanCastedExpr($node->expr);
}
$this->removeNode($node);
return $node;
return null;
}
private function cleanCastedExpr(Expr $expr) : Expr
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function refactor(Node $node) : ?Node
return null;
}
$this->removeNode($node);
return $node;
return null;
}
private function shouldSkipNonFinalNonPrivateClassMethod(Class_ $class, ClassMethod $classMethod) : bool
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function refactor(Node $node) : ?Node
return null;
}
$this->removeNode($node);
return $node;
return null;
}
private function shouldSkip(ClassMethod $classMethod) : bool
{
Expand Down
2 changes: 1 addition & 1 deletion rules/DeadCode/Rector/For_/RemoveDeadLoopRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@ public function refactor(Node $node) : ?Node
return null;
}
$this->removeNode($node);
return $node;
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public function refactor(Node $node) : ?Node
return null;
}
$this->removeNode($node);
return $node;
return null;
}
private function resolveClassLike(MethodCall $methodCall) : ?ClassLike
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function refactor(Node $node)
}
if ($this->isEmpty($node->stmts)) {
$this->removeNode($node);
return $node;
return null;
}
if (\count($node->catches) !== 1) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,6 @@ public function refactor(Node $node) : ?Node
return new Return_();
}
$this->removeNode($node);
return $node;
return null;
}
}
1 change: 1 addition & 0 deletions rules/Php73/Rector/FuncCall/ArrayKeyFirstLastRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ public function refactor(Node $node) : ?Node
$newName = self::PREVIOUS_TO_NEW_FUNCTIONS[$this->getName($node)];
$keyFuncCall->name = new Name($newName);
$this->removeNode($node);
// change next node before remove, so it needs to return the Node
return $node;
}
public function provideMinPhpVersion() : int
Expand Down
4 changes: 2 additions & 2 deletions src/Application/VersionResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '3cbf7104d0b81ba1b930ce9a4cd3456e1c082b43';
public const PACKAGE_VERSION = '5e5681d9edbb438b5782b45fde6e88650aa3843f';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2023-04-02 21:40:41';
public const RELEASE_DATE = '2023-04-04 00:15:55';
/**
* @var int
*/
Expand Down
6 changes: 3 additions & 3 deletions src/Rector/AbstractRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ abstract class AbstractRector extends NodeVisitorAbstract implements PhpRectorIn
private const EMPTY_NODE_ARRAY_MESSAGE = <<<CODE_SAMPLE
Array of nodes cannot be empty. Ensure "%s->refactor()" returns non-empty array for Nodes.
A) Return null for no change:
A) Direct return null for no change:
return null;
B) Remove the Node:
\$this->removeNode(\$node);
return \$node;
return null;
CODE_SAMPLE;
/**
* @var \Rector\NodeNameResolver\NodeNameResolver
Expand Down Expand Up @@ -218,7 +218,7 @@ public final function enterNode(Node $node)
$this->changedNodeScopeRefresher->reIndexNodeAttributes($node);
}
$refactoredNode = $this->refactor($node);
// nothing to change → continue
// nothing to change or just removed via removeNode() → continue
if ($refactoredNode === null) {
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion vendor/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@

require_once __DIR__ . '/composer/autoload_real.php';

return ComposerAutoloaderInit4c05484305864b0e5733b0ca9f0cc86e::getLoader();
return ComposerAutoloaderInit277ffbed55498b11c1ef07f9e681665e::getLoader();
10 changes: 5 additions & 5 deletions vendor/composer/autoload_real.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// autoload_real.php @generated by Composer

class ComposerAutoloaderInit4c05484305864b0e5733b0ca9f0cc86e
class ComposerAutoloaderInit277ffbed55498b11c1ef07f9e681665e
{
private static $loader;

Expand All @@ -22,17 +22,17 @@ public static function getLoader()
return self::$loader;
}

spl_autoload_register(array('ComposerAutoloaderInit4c05484305864b0e5733b0ca9f0cc86e', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit277ffbed55498b11c1ef07f9e681665e', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInit4c05484305864b0e5733b0ca9f0cc86e', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit277ffbed55498b11c1ef07f9e681665e', 'loadClassLoader'));

require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit4c05484305864b0e5733b0ca9f0cc86e::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit277ffbed55498b11c1ef07f9e681665e::getInitializer($loader));

$loader->setClassMapAuthoritative(true);
$loader->register(true);

$filesToLoad = \Composer\Autoload\ComposerStaticInit4c05484305864b0e5733b0ca9f0cc86e::$files;
$filesToLoad = \Composer\Autoload\ComposerStaticInit277ffbed55498b11c1ef07f9e681665e::$files;
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
Expand Down
8 changes: 4 additions & 4 deletions vendor/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Composer\Autoload;

class ComposerStaticInit4c05484305864b0e5733b0ca9f0cc86e
class ComposerStaticInit277ffbed55498b11c1ef07f9e681665e
{
public static $files = array (
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
Expand Down Expand Up @@ -3131,9 +3131,9 @@ class ComposerStaticInit4c05484305864b0e5733b0ca9f0cc86e
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit4c05484305864b0e5733b0ca9f0cc86e::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit4c05484305864b0e5733b0ca9f0cc86e::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit4c05484305864b0e5733b0ca9f0cc86e::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit277ffbed55498b11c1ef07f9e681665e::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit277ffbed55498b11c1ef07f9e681665e::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit277ffbed55498b11c1ef07f9e681665e::$classMap;

}, null, ClassLoader::class);
}
Expand Down

0 comments on commit f5640c1

Please sign in to comment.