Updated Rector to commit 279126145e995c4d0b39a60bd6fc5fff5799199e

279126145e Refactor PARENT_NODE away from UnsetCastRector (#3945)
This commit is contained in:
Tomas Votruba 2023-05-24 09:42:43 +00:00
parent d7eced92e2
commit 13cb0fa921
5 changed files with 31 additions and 24 deletions

View File

@ -6,10 +6,10 @@ namespace Rector\Php72\Rector\Unset_;
use PhpParser\Node;
use PhpParser\Node\Expr\Assign;
use PhpParser\Node\Expr\Cast\Unset_;
use PhpParser\Node\Expr\FuncCall;
use PhpParser\Node\Stmt\Expression;
use Rector\Core\Rector\AbstractRector;
use Rector\Core\ValueObject\PhpVersionFeature;
use Rector\NodeTypeResolver\Node\AttributeKey;
use Rector\VersionBonding\Contract\MinPhpVersionInterface;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
@ -41,27 +41,34 @@ CODE_SAMPLE
*/
public function getNodeTypes() : array
{
return [Unset_::class, Assign::class];
return [Unset_::class, Assign::class, Expression::class];
}
/**
* @param Unset_|Assign $node
* @param Unset_|Assign|Expression $node
*/
public function refactor(Node $node) : ?Node
{
if ($node instanceof Assign) {
if ($node->expr instanceof Unset_) {
$unset = $node->expr;
if ($this->nodeComparator->areNodesEqual($node->var, $unset->expr)) {
return $this->nodeFactory->createFuncCall('unset', [$node->var]);
}
}
return null;
return $this->refactorAssign($node);
}
$parentNode = $node->getAttribute(AttributeKey::PARENT_NODE);
if ($parentNode instanceof Expression) {
if ($node instanceof Expression) {
if (!$node->expr instanceof Unset_) {
return null;
}
$this->removeNode($node);
return null;
}
return $this->nodeFactory->createNull();
}
private function refactorAssign(Assign $assign) : ?FuncCall
{
if (!$assign->expr instanceof Unset_) {
return null;
}
$unset = $assign->expr;
if (!$this->nodeComparator->areNodesEqual($assign->var, $unset->expr)) {
return null;
}
return $this->nodeFactory->createFuncCall('unset', [$assign->var]);
}
}

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = 'c504b2f11f2b732a744ad804b3a4b5afc30e2841';
public const PACKAGE_VERSION = '279126145e995c4d0b39a60bd6fc5fff5799199e';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2023-05-24 09:31:55';
public const RELEASE_DATE = '2023-05-24 09:38:51';
/**
* @var int
*/

2
vendor/autoload.php vendored
View File

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

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInitd1e79f67f253438ff69fc93ef401a7af
class ComposerAutoloaderInit68fa97b402c8b0e8b73786dcfe58719b
{
private static $loader;
@ -22,17 +22,17 @@ class ComposerAutoloaderInitd1e79f67f253438ff69fc93ef401a7af
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInitd1e79f67f253438ff69fc93ef401a7af', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit68fa97b402c8b0e8b73786dcfe58719b', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInitd1e79f67f253438ff69fc93ef401a7af', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit68fa97b402c8b0e8b73786dcfe58719b', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInitd1e79f67f253438ff69fc93ef401a7af::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit68fa97b402c8b0e8b73786dcfe58719b::getInitializer($loader));
$loader->setClassMapAuthoritative(true);
$loader->register(true);
$filesToLoad = \Composer\Autoload\ComposerStaticInitd1e79f67f253438ff69fc93ef401a7af::$files;
$filesToLoad = \Composer\Autoload\ComposerStaticInit68fa97b402c8b0e8b73786dcfe58719b::$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 ComposerStaticInitd1e79f67f253438ff69fc93ef401a7af
class ComposerStaticInit68fa97b402c8b0e8b73786dcfe58719b
{
public static $files = array (
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
@ -3106,9 +3106,9 @@ class ComposerStaticInitd1e79f67f253438ff69fc93ef401a7af
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInitd1e79f67f253438ff69fc93ef401a7af::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitd1e79f67f253438ff69fc93ef401a7af::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitd1e79f67f253438ff69fc93ef401a7af::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit68fa97b402c8b0e8b73786dcfe58719b::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit68fa97b402c8b0e8b73786dcfe58719b::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit68fa97b402c8b0e8b73786dcfe58719b::$classMap;
}, null, ClassLoader::class);
}