Updated Rector to commit 31712a1a466b4f2f2f83986aa6710405a00b446e

31712a1a46 Refactor from PARENT_NODE in TokenGetAllToObjectRector (#3961)
This commit is contained in:
Tomas Votruba 2023-05-25 13:52:45 +00:00
parent 94c1b64b7e
commit 0efdb38927
5 changed files with 25 additions and 24 deletions

View File

@ -89,32 +89,33 @@ CODE_SAMPLE
*/
public function getNodeTypes() : array
{
return [FuncCall::class];
return [Assign::class];
}
/**
* @param FuncCall $node
* @param Assign $node
*/
public function refactor(Node $node) : ?Node
{
if (!$this->nodeNameResolver->isName($node, 'token_get_all')) {
if (!$node->expr instanceof FuncCall) {
return null;
}
$this->refactorTokensVariable($node);
return $this->nodeFactory->createStaticCall('PhpToken', 'tokenize', $node->args);
}
private function refactorTokensVariable(FuncCall $funcCall) : void
{
$parentNode = $funcCall->getAttribute(AttributeKey::PARENT_NODE);
if (!$parentNode instanceof Assign) {
return;
$funcCall = $node->expr;
if (!$this->nodeNameResolver->isName($funcCall, 'token_get_all')) {
return null;
}
$this->refactorTokensVariable($funcCall, $node->var);
$node->expr = $this->nodeFactory->createStaticCall('PhpToken', 'tokenize', $funcCall->getArgs());
return $node;
}
private function refactorTokensVariable(FuncCall $funcCall, Expr $assignedToExpr) : void
{
/** @var ClassMethod|Function_|null $classMethodOrFunction */
$classMethodOrFunction = $this->betterNodeFinder->findParentByTypes($funcCall, [ClassMethod::class, Function_::class]);
if ($classMethodOrFunction === null) {
return;
}
// dummy approach, improve when needed
$this->replaceGetNameOrGetValue($classMethodOrFunction, $parentNode->var);
$this->replaceGetNameOrGetValue($classMethodOrFunction, $assignedToExpr);
}
/**
* @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_ $functionLike

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '18ac565714b7b66506a901ed4787d1ffbdd0af2d';
public const PACKAGE_VERSION = '31712a1a466b4f2f2f83986aa6710405a00b446e';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2023-05-25 13:41:36';
public const RELEASE_DATE = '2023-05-25 14:47:21';
/**
* @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 ComposerAutoloaderInit7f64ef7824bb76b016efb10fc81d1197::getLoader();
return ComposerAutoloaderInitd3ebb4841d8cc350ea32a81b58fc1e1a::getLoader();

View File

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