mirror of
https://github.com/rectorphp/rector.git
synced 2025-04-16 05:22:00 +02:00
Updated Rector to commit c203b601c98f4a93236c82179a2e9a5a519b48ae
c203b601c9
[Php80] Handle crash leaveNode() returned invalid value of type integer on TokenGetAllToObjectRector (#3644)
This commit is contained in:
parent
3e22fca2fe
commit
30c4c5527a
@ -8,7 +8,9 @@ use PhpParser\Node\Arg;
|
||||
use PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Expr\ArrayDimFetch;
|
||||
use PhpParser\Node\Expr\Assign;
|
||||
use PhpParser\Node\Expr\BinaryOp;
|
||||
use PhpParser\Node\Expr\BinaryOp\Identical;
|
||||
use PhpParser\Node\Expr\BinaryOp\NotIdentical;
|
||||
use PhpParser\Node\Expr\BooleanNot;
|
||||
use PhpParser\Node\Expr\ConstFetch;
|
||||
use PhpParser\Node\Expr\FuncCall;
|
||||
@ -152,10 +154,11 @@ final class TokenManipulator
|
||||
*/
|
||||
public function refactorTokenIsKind(array $nodes, Variable $singleTokenVariable) : void
|
||||
{
|
||||
$this->simpleCallableNodeTraverser->traverseNodesWithCallable($nodes, function (Node $node) use($singleTokenVariable) : ?MethodCall {
|
||||
if (!$node instanceof Identical) {
|
||||
$this->simpleCallableNodeTraverser->traverseNodesWithCallable($nodes, function (Node $node) use($singleTokenVariable) {
|
||||
if (!$this->isIdenticalOrNotIdentical($node)) {
|
||||
return null;
|
||||
}
|
||||
/** @var Identical|NotIdentical $node */
|
||||
$arrayDimFetchAndConstFetch = $this->matchArrayDimFetchAndConstFetch($node);
|
||||
if (!$arrayDimFetchAndConstFetch instanceof ArrayDimFetchAndConstFetch) {
|
||||
return null;
|
||||
@ -168,14 +171,15 @@ final class TokenManipulator
|
||||
if (!$this->nodeComparator->areNodesEqual($arrayDimFetch->var, $singleTokenVariable)) {
|
||||
return null;
|
||||
}
|
||||
$constName = $this->nodeNameResolver->getName($constFetch);
|
||||
if ($constName === null) {
|
||||
return null;
|
||||
}
|
||||
$constName = (string) $this->nodeNameResolver->getName($constFetch);
|
||||
if (!StringUtils::isMatch($constName, '#^T_#')) {
|
||||
return null;
|
||||
}
|
||||
return $this->createIsTConstTypeMethodCall($arrayDimFetch, $arrayDimFetchAndConstFetch->getConstFetch());
|
||||
$isTConstTypeMethodCall = $this->createIsTConstTypeMethodCall($arrayDimFetch, $arrayDimFetchAndConstFetch->getConstFetch());
|
||||
if ($node instanceof Identical) {
|
||||
return $isTConstTypeMethodCall;
|
||||
}
|
||||
return new BooleanNot($isTConstTypeMethodCall);
|
||||
});
|
||||
}
|
||||
/**
|
||||
@ -208,10 +212,23 @@ final class TokenManipulator
|
||||
$this->replaceTernary($parentNode);
|
||||
return $node;
|
||||
}
|
||||
if (!$parentNode instanceof BooleanNot) {
|
||||
$this->nodesToRemoveCollector->addNodeToRemove($nodeToRemove);
|
||||
return $node;
|
||||
}
|
||||
$parentOfParentNode = $parentNode->getAttribute(AttributeKey::PARENT_NODE);
|
||||
if ($parentOfParentNode instanceof BinaryOp) {
|
||||
$this->nodesToRemoveCollector->addNodeToRemove($parentNode);
|
||||
return $node;
|
||||
}
|
||||
$this->nodesToRemoveCollector->addNodeToRemove($nodeToRemove);
|
||||
return $node;
|
||||
});
|
||||
}
|
||||
private function isIdenticalOrNotIdentical(Node $node) : bool
|
||||
{
|
||||
return $node instanceof Identical || $node instanceof NotIdentical;
|
||||
}
|
||||
private function replaceTernary(Ternary $ternary) : void
|
||||
{
|
||||
$currentStmt = $this->betterNodeFinder->resolveCurrentStatement($ternary);
|
||||
@ -273,7 +290,10 @@ final class TokenManipulator
|
||||
}
|
||||
return $this->valueResolver->isValue($arrayDimFetch->dim, $value);
|
||||
}
|
||||
private function matchArrayDimFetchAndConstFetch(Identical $identical) : ?ArrayDimFetchAndConstFetch
|
||||
/**
|
||||
* @param \PhpParser\Node\Expr\BinaryOp\Identical|\PhpParser\Node\Expr\BinaryOp\NotIdentical $identical
|
||||
*/
|
||||
private function matchArrayDimFetchAndConstFetch($identical) : ?ArrayDimFetchAndConstFetch
|
||||
{
|
||||
if ($identical->left instanceof ArrayDimFetch && $identical->right instanceof ConstFetch) {
|
||||
return new ArrayDimFetchAndConstFetch($identical->left, $identical->right);
|
||||
@ -297,12 +317,13 @@ final class TokenManipulator
|
||||
if ($parentNode instanceof If_ && $parentNode->cond === $funcCall) {
|
||||
return \true;
|
||||
}
|
||||
if ($parentNode instanceof BooleanNot) {
|
||||
$parentParentNode = $parentNode->getAttribute(AttributeKey::PARENT_NODE);
|
||||
if ($parentParentNode instanceof If_) {
|
||||
$parentParentNode->cond = $parentNode;
|
||||
return \true;
|
||||
}
|
||||
if (!$parentNode instanceof BooleanNot) {
|
||||
return \false;
|
||||
}
|
||||
$parentParentNode = $parentNode->getAttribute(AttributeKey::PARENT_NODE);
|
||||
if ($parentParentNode instanceof If_) {
|
||||
$parentParentNode->cond = $parentNode;
|
||||
return \true;
|
||||
}
|
||||
return \false;
|
||||
}
|
||||
@ -312,16 +333,20 @@ final class TokenManipulator
|
||||
private function matchParentNodeInCaseOfIdenticalTrue(FuncCall $funcCall)
|
||||
{
|
||||
$parentNode = $funcCall->getAttribute(AttributeKey::PARENT_NODE);
|
||||
if ($parentNode instanceof Identical) {
|
||||
$isRightValueTrue = $this->valueResolver->isValue($parentNode->right, \true);
|
||||
if ($parentNode->left === $funcCall && $isRightValueTrue) {
|
||||
return $parentNode;
|
||||
}
|
||||
$isLeftValueTrue = $this->valueResolver->isValue($parentNode->left, \true);
|
||||
if ($parentNode->right === $funcCall && $isLeftValueTrue) {
|
||||
return $parentNode;
|
||||
}
|
||||
if (!$parentNode instanceof Identical) {
|
||||
return $funcCall;
|
||||
}
|
||||
return $funcCall;
|
||||
$isRightValueTrue = $this->valueResolver->isValue($parentNode->right, \true);
|
||||
if ($parentNode->left === $funcCall && $isRightValueTrue) {
|
||||
return $parentNode;
|
||||
}
|
||||
$isLeftValueTrue = $this->valueResolver->isValue($parentNode->left, \true);
|
||||
if ($parentNode->right !== $funcCall) {
|
||||
return $funcCall;
|
||||
}
|
||||
if (!$isLeftValueTrue) {
|
||||
return $funcCall;
|
||||
}
|
||||
return $parentNode;
|
||||
}
|
||||
}
|
||||
|
@ -19,12 +19,12 @@ final class VersionResolver
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = 'add55824f64b4b597a6b3bc3feb9a557708ace00';
|
||||
public const PACKAGE_VERSION = 'c203b601c98f4a93236c82179a2e9a5a519b48ae';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2023-04-21 18:56:48';
|
||||
public const RELEASE_DATE = '2023-04-21 16:23:38';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
2
vendor/autoload.php
vendored
2
vendor/autoload.php
vendored
@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) {
|
||||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInit59528c1ec1ddd40a116ee19c41b4ab63::getLoader();
|
||||
return ComposerAutoloaderInit45bf6ce75610d1a911507cf4dc2cf860::getLoader();
|
||||
|
10
vendor/composer/autoload_real.php
vendored
10
vendor/composer/autoload_real.php
vendored
@ -2,7 +2,7 @@
|
||||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInit59528c1ec1ddd40a116ee19c41b4ab63
|
||||
class ComposerAutoloaderInit45bf6ce75610d1a911507cf4dc2cf860
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
@ -22,17 +22,17 @@ class ComposerAutoloaderInit59528c1ec1ddd40a116ee19c41b4ab63
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit59528c1ec1ddd40a116ee19c41b4ab63', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit45bf6ce75610d1a911507cf4dc2cf860', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit59528c1ec1ddd40a116ee19c41b4ab63', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit45bf6ce75610d1a911507cf4dc2cf860', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit59528c1ec1ddd40a116ee19c41b4ab63::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit45bf6ce75610d1a911507cf4dc2cf860::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInit59528c1ec1ddd40a116ee19c41b4ab63::$files;
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInit45bf6ce75610d1a911507cf4dc2cf860::$files;
|
||||
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||
|
8
vendor/composer/autoload_static.php
vendored
8
vendor/composer/autoload_static.php
vendored
@ -4,7 +4,7 @@
|
||||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInit59528c1ec1ddd40a116ee19c41b4ab63
|
||||
class ComposerStaticInit45bf6ce75610d1a911507cf4dc2cf860
|
||||
{
|
||||
public static $files = array (
|
||||
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
|
||||
@ -3149,9 +3149,9 @@ class ComposerStaticInit59528c1ec1ddd40a116ee19c41b4ab63
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit59528c1ec1ddd40a116ee19c41b4ab63::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit59528c1ec1ddd40a116ee19c41b4ab63::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit59528c1ec1ddd40a116ee19c41b4ab63::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit45bf6ce75610d1a911507cf4dc2cf860::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit45bf6ce75610d1a911507cf4dc2cf860::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit45bf6ce75610d1a911507cf4dc2cf860::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user