From fb290ae9afc4079868d2804927a05d98a068e36e Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Sat, 14 Aug 2021 22:33:29 +0000 Subject: [PATCH] Updated Rector to commit edc280c9f15da2e54868c153f5a108d3552bc2e1 https://github.com/rectorphp/rector-src/commit/edc280c9f15da2e54868c153f5a108d3552bc2e1 Fix for NullsafeOperatorRector crashing on returning null if both returns are null (#682) --- .../Rector/If_/NullsafeOperatorRector.php | 27 ++++++++++++++----- src/Application/VersionResolver.php | 4 +-- vendor/autoload.php | 2 +- vendor/composer/autoload_real.php | 14 +++++----- vendor/composer/autoload_static.php | 8 +++--- vendor/scoper-autoload.php | 10 +++---- 6 files changed, 39 insertions(+), 26 deletions(-) diff --git a/rules/Php80/Rector/If_/NullsafeOperatorRector.php b/rules/Php80/Rector/If_/NullsafeOperatorRector.php index b12c2e86109..7b437a63e4f 100644 --- a/rules/Php80/Rector/If_/NullsafeOperatorRector.php +++ b/rules/Php80/Rector/If_/NullsafeOperatorRector.php @@ -110,22 +110,19 @@ CODE_SAMPLE } $prevNode = $if->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PREVIOUS_NODE); $nextNode = $if->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::NEXT_NODE); - if (!$prevNode instanceof \PhpParser\Node) { - return null; - } if (!$nextNode instanceof \PhpParser\Node) { return null; } if (!$prevNode instanceof \PhpParser\Node\Stmt\Expression) { return null; } - if (!$this->ifManipulator->isIfCondUsingAssignIdenticalVariable($if, $prevNode->expr)) { - return null; - } $prevExpr = $prevNode->expr; if (!$prevExpr instanceof \PhpParser\Node\Expr\Assign) { return null; } + if (!$this->ifManipulator->isIfCondUsingAssignIdenticalVariable($if, $prevExpr)) { + return null; + } return $this->processAssign($prevExpr, $prevNode, $nextNode, $isStartIf); } private function processNullSafeOperatorNotIdentical(\PhpParser\Node\Stmt\If_ $if, ?\PhpParser\Node\Expr $expr = null) : ?\PhpParser\Node @@ -196,11 +193,27 @@ CODE_SAMPLE } private function processAssign(\PhpParser\Node\Expr\Assign $assign, \PhpParser\Node\Stmt\Expression $prevExpression, \PhpParser\Node $nextNode, bool $isStartIf) : ?\PhpParser\Node { - if ($assign instanceof \PhpParser\Node\Expr\Assign && \property_exists($assign->expr, self::NAME) && \property_exists($nextNode, 'expr') && \property_exists($nextNode->expr, self::NAME)) { + if ($this->shouldProcessAssignInCurrentNode($assign, $nextNode)) { return $this->processAssignInCurrentNode($assign, $prevExpression, $nextNode, $isStartIf); } return $this->processAssignMayInNextNode($nextNode); } + private function shouldProcessAssignInCurrentNode(\PhpParser\Node\Expr\Assign $assign, \PhpParser\Node $nextNode) : bool + { + if (!\property_exists($assign->expr, self::NAME)) { + return \false; + } + if (!\property_exists($nextNode, 'expr')) { + return \false; + } + if (!\property_exists($nextNode->expr, self::NAME)) { + return \false; + } + if ($this->valueResolver->isNull($nextNode->expr)) { + return \false; + } + return \true; + } private function processIfMayInNextNode(?\PhpParser\Node $nextNode = null) : ?\PhpParser\Node { if (!$nextNode instanceof \PhpParser\Node) { diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index 022513368b5..dae8e9ee4fd 100644 --- a/src/Application/VersionResolver.php +++ b/src/Application/VersionResolver.php @@ -16,11 +16,11 @@ final class VersionResolver /** * @var string */ - public const PACKAGE_VERSION = '13d73b380d5adedbccbe37afb0aff2e2319a7e27'; + public const PACKAGE_VERSION = 'edc280c9f15da2e54868c153f5a108d3552bc2e1'; /** * @var string */ - public const RELEASE_DATE = '2021-08-14 15:01:18'; + public const RELEASE_DATE = '2021-08-15 00:22:32'; public static function resolvePackageVersion() : string { $process = new \RectorPrefix20210814\Symfony\Component\Process\Process(['git', 'log', '--pretty="%H"', '-n1', 'HEAD'], __DIR__); diff --git a/vendor/autoload.php b/vendor/autoload.php index 4135eb00caa..37b0add95d5 100644 --- a/vendor/autoload.php +++ b/vendor/autoload.php @@ -4,4 +4,4 @@ require_once __DIR__ . '/composer/autoload_real.php'; -return ComposerAutoloaderInitf26c79c5e093c4f31e58f89d8ab5d9cb::getLoader(); +return ComposerAutoloaderInit4a469242abcb15bd898a2c45bcf45e76::getLoader(); diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index 901bb905904..354bb00b952 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInitf26c79c5e093c4f31e58f89d8ab5d9cb +class ComposerAutoloaderInit4a469242abcb15bd898a2c45bcf45e76 { private static $loader; @@ -22,15 +22,15 @@ class ComposerAutoloaderInitf26c79c5e093c4f31e58f89d8ab5d9cb return self::$loader; } - spl_autoload_register(array('ComposerAutoloaderInitf26c79c5e093c4f31e58f89d8ab5d9cb', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInit4a469242abcb15bd898a2c45bcf45e76', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__))); - spl_autoload_unregister(array('ComposerAutoloaderInitf26c79c5e093c4f31e58f89d8ab5d9cb', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInit4a469242abcb15bd898a2c45bcf45e76', 'loadClassLoader')); $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); if ($useStaticLoader) { require __DIR__ . '/autoload_static.php'; - call_user_func(\Composer\Autoload\ComposerStaticInitf26c79c5e093c4f31e58f89d8ab5d9cb::getInitializer($loader)); + call_user_func(\Composer\Autoload\ComposerStaticInit4a469242abcb15bd898a2c45bcf45e76::getInitializer($loader)); } else { $classMap = require __DIR__ . '/autoload_classmap.php'; if ($classMap) { @@ -42,19 +42,19 @@ class ComposerAutoloaderInitf26c79c5e093c4f31e58f89d8ab5d9cb $loader->register(true); if ($useStaticLoader) { - $includeFiles = Composer\Autoload\ComposerStaticInitf26c79c5e093c4f31e58f89d8ab5d9cb::$files; + $includeFiles = Composer\Autoload\ComposerStaticInit4a469242abcb15bd898a2c45bcf45e76::$files; } else { $includeFiles = require __DIR__ . '/autoload_files.php'; } foreach ($includeFiles as $fileIdentifier => $file) { - composerRequiref26c79c5e093c4f31e58f89d8ab5d9cb($fileIdentifier, $file); + composerRequire4a469242abcb15bd898a2c45bcf45e76($fileIdentifier, $file); } return $loader; } } -function composerRequiref26c79c5e093c4f31e58f89d8ab5d9cb($fileIdentifier, $file) +function composerRequire4a469242abcb15bd898a2c45bcf45e76($fileIdentifier, $file) { if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { require $file; diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index 0dd588c36cf..1237b861177 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -4,7 +4,7 @@ namespace Composer\Autoload; -class ComposerStaticInitf26c79c5e093c4f31e58f89d8ab5d9cb +class ComposerStaticInit4a469242abcb15bd898a2c45bcf45e76 { public static $files = array ( 'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php', @@ -3850,9 +3850,9 @@ class ComposerStaticInitf26c79c5e093c4f31e58f89d8ab5d9cb public static function getInitializer(ClassLoader $loader) { return \Closure::bind(function () use ($loader) { - $loader->prefixLengthsPsr4 = ComposerStaticInitf26c79c5e093c4f31e58f89d8ab5d9cb::$prefixLengthsPsr4; - $loader->prefixDirsPsr4 = ComposerStaticInitf26c79c5e093c4f31e58f89d8ab5d9cb::$prefixDirsPsr4; - $loader->classMap = ComposerStaticInitf26c79c5e093c4f31e58f89d8ab5d9cb::$classMap; + $loader->prefixLengthsPsr4 = ComposerStaticInit4a469242abcb15bd898a2c45bcf45e76::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInit4a469242abcb15bd898a2c45bcf45e76::$prefixDirsPsr4; + $loader->classMap = ComposerStaticInit4a469242abcb15bd898a2c45bcf45e76::$classMap; }, null, ClassLoader::class); } diff --git a/vendor/scoper-autoload.php b/vendor/scoper-autoload.php index 9bbc52b9d69..9400f162b6e 100644 --- a/vendor/scoper-autoload.php +++ b/vendor/scoper-autoload.php @@ -9,8 +9,8 @@ $loader = require_once __DIR__.'/autoload.php'; if (!class_exists('AutoloadIncluder', false) && !interface_exists('AutoloadIncluder', false) && !trait_exists('AutoloadIncluder', false)) { spl_autoload_call('RectorPrefix20210814\AutoloadIncluder'); } -if (!class_exists('ComposerAutoloaderInitf26c79c5e093c4f31e58f89d8ab5d9cb', false) && !interface_exists('ComposerAutoloaderInitf26c79c5e093c4f31e58f89d8ab5d9cb', false) && !trait_exists('ComposerAutoloaderInitf26c79c5e093c4f31e58f89d8ab5d9cb', false)) { - spl_autoload_call('RectorPrefix20210814\ComposerAutoloaderInitf26c79c5e093c4f31e58f89d8ab5d9cb'); +if (!class_exists('ComposerAutoloaderInit4a469242abcb15bd898a2c45bcf45e76', false) && !interface_exists('ComposerAutoloaderInit4a469242abcb15bd898a2c45bcf45e76', false) && !trait_exists('ComposerAutoloaderInit4a469242abcb15bd898a2c45bcf45e76', false)) { + spl_autoload_call('RectorPrefix20210814\ComposerAutoloaderInit4a469242abcb15bd898a2c45bcf45e76'); } if (!class_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false) && !interface_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false) && !trait_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false)) { spl_autoload_call('RectorPrefix20210814\Helmich\TypoScriptParser\Parser\AST\Statement'); @@ -3308,9 +3308,9 @@ if (!function_exists('print_node')) { return \RectorPrefix20210814\print_node(...func_get_args()); } } -if (!function_exists('composerRequiref26c79c5e093c4f31e58f89d8ab5d9cb')) { - function composerRequiref26c79c5e093c4f31e58f89d8ab5d9cb() { - return \RectorPrefix20210814\composerRequiref26c79c5e093c4f31e58f89d8ab5d9cb(...func_get_args()); +if (!function_exists('composerRequire4a469242abcb15bd898a2c45bcf45e76')) { + function composerRequire4a469242abcb15bd898a2c45bcf45e76() { + return \RectorPrefix20210814\composerRequire4a469242abcb15bd898a2c45bcf45e76(...func_get_args()); } } if (!function_exists('parseArgs')) {