Updated Rector to commit 81e326c2ff3957fe65c2bba5a85bad57887c7c8f

81e326c2ff [DeadCode] Handle RemoveUnusedPrivateMethodRector+RemoveDuplicatedIfReturnRector when private method used in FuncCall with ArrowFunction (#3007)
This commit is contained in:
Tomas Votruba 2022-10-22 09:55:21 +00:00
parent 65d5921fd9
commit 10e29c44d8
5 changed files with 48 additions and 14 deletions

View File

@ -4,8 +4,12 @@ declare (strict_types=1);
namespace Rector\PhpDocParser\NodeTraverser;
use PhpParser\Node;
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\ArrowFunction;
use PhpParser\Node\Stmt\Return_;
use PhpParser\NodeTraverser;
use PhpParser\NodeVisitor\ParentConnectingVisitor;
use Rector\NodeTypeResolver\Node\AttributeKey;
use Rector\PhpDocParser\NodeVisitor\CallableNodeVisitor;
/**
* @api
@ -30,7 +34,37 @@ final class SimpleCallableNodeTraverser
$nodeTraverser = new NodeTraverser();
$callableNodeVisitor = new CallableNodeVisitor($callable);
$nodeTraverser->addVisitor($callableNodeVisitor);
$this->mirrorParentReturnArrowFunction($nodes);
$nodeTraverser->addVisitor(new ParentConnectingVisitor());
$nodeTraverser->traverse($nodes);
}
/**
* The ArrowFunction when call ->getStmts(), it returns
*
* return [new Node\Stmt\Return_($this->expr)]
*
* The $expr property has parent Node ArrowFunction, but not the Return_ stmt,
* so need to mirror $expr parent Node into Return_ stmt
*
* @param Node[] $nodes
*/
private function mirrorParentReturnArrowFunction(array $nodes) : void
{
foreach ($nodes as $node) {
if (!$node instanceof Return_) {
continue;
}
if (!$node->expr instanceof Expr) {
continue;
}
$parentNode = $node->getAttribute(AttributeKey::PARENT_NODE);
if ($parentNode instanceof Node) {
continue;
}
$exprParent = $node->expr->getAttribute(AttributeKey::PARENT_NODE);
if ($exprParent instanceof ArrowFunction) {
$node->setAttribute(AttributeKey::PARENT_NODE, $exprParent);
}
}
}
}

View File

@ -17,12 +17,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '1dcd9faf6d5eae5b911f764c6877343774b6a359';
public const PACKAGE_VERSION = '81e326c2ff3957fe65c2bba5a85bad57887c7c8f';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2022-10-22 11:48:59';
public const RELEASE_DATE = '2022-10-22 11:50: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 ComposerAutoloaderInit254a0092bb6441f45a8d5ef4a78ef78e::getLoader();
return ComposerAutoloaderInit8a3ec1ae6425d97636fe74bab82942de::getLoader();

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit254a0092bb6441f45a8d5ef4a78ef78e
class ComposerAutoloaderInit8a3ec1ae6425d97636fe74bab82942de
{
private static $loader;
@ -22,19 +22,19 @@ class ComposerAutoloaderInit254a0092bb6441f45a8d5ef4a78ef78e
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit254a0092bb6441f45a8d5ef4a78ef78e', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit8a3ec1ae6425d97636fe74bab82942de', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInit254a0092bb6441f45a8d5ef4a78ef78e', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit8a3ec1ae6425d97636fe74bab82942de', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit254a0092bb6441f45a8d5ef4a78ef78e::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit8a3ec1ae6425d97636fe74bab82942de::getInitializer($loader));
$loader->setClassMapAuthoritative(true);
$loader->register(true);
$includeFiles = \Composer\Autoload\ComposerStaticInit254a0092bb6441f45a8d5ef4a78ef78e::$files;
$includeFiles = \Composer\Autoload\ComposerStaticInit8a3ec1ae6425d97636fe74bab82942de::$files;
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequire254a0092bb6441f45a8d5ef4a78ef78e($fileIdentifier, $file);
composerRequire8a3ec1ae6425d97636fe74bab82942de($fileIdentifier, $file);
}
return $loader;
@ -46,7 +46,7 @@ class ComposerAutoloaderInit254a0092bb6441f45a8d5ef4a78ef78e
* @param string $file
* @return void
*/
function composerRequire254a0092bb6441f45a8d5ef4a78ef78e($fileIdentifier, $file)
function composerRequire8a3ec1ae6425d97636fe74bab82942de($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 ComposerStaticInit254a0092bb6441f45a8d5ef4a78ef78e
class ComposerStaticInit8a3ec1ae6425d97636fe74bab82942de
{
public static $files = array (
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
@ -3093,9 +3093,9 @@ class ComposerStaticInit254a0092bb6441f45a8d5ef4a78ef78e
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit254a0092bb6441f45a8d5ef4a78ef78e::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit254a0092bb6441f45a8d5ef4a78ef78e::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit254a0092bb6441f45a8d5ef4a78ef78e::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit8a3ec1ae6425d97636fe74bab82942de::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit8a3ec1ae6425d97636fe74bab82942de::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit8a3ec1ae6425d97636fe74bab82942de::$classMap;
}, null, ClassLoader::class);
}