mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-19 06:18:07 +01:00
Updated Rector to commit edc280c9f15da2e54868c153f5a108d3552bc2e1
edc280c9f1
Fix for NullsafeOperatorRector crashing on returning null if both returns are null (#682)
This commit is contained in:
parent
17c50e80ed
commit
fb290ae9af
@ -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) {
|
||||
|
@ -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__);
|
||||
|
2
vendor/autoload.php
vendored
2
vendor/autoload.php
vendored
@ -4,4 +4,4 @@
|
||||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInitf26c79c5e093c4f31e58f89d8ab5d9cb::getLoader();
|
||||
return ComposerAutoloaderInit4a469242abcb15bd898a2c45bcf45e76::getLoader();
|
||||
|
14
vendor/composer/autoload_real.php
vendored
14
vendor/composer/autoload_real.php
vendored
@ -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;
|
||||
|
8
vendor/composer/autoload_static.php
vendored
8
vendor/composer/autoload_static.php
vendored
@ -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);
|
||||
}
|
||||
|
10
vendor/scoper-autoload.php
vendored
10
vendor/scoper-autoload.php
vendored
@ -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')) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user