mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-21 10:32:24 +00:00
Updated Rector to commit 6156458ef43b1961a0ded5df85ca3fa4c35686e9
6156458ef4
Drop AttributeKey::SCOPE in AssignAndBinaryMap (#3861)
This commit is contained in:
parent
1b8d2812ef
commit
86d7e3ad58
|
@ -8,16 +8,17 @@ use PhpParser\Node\Expr;
|
||||||
use PhpParser\Node\Expr\BinaryOp\BooleanAnd;
|
use PhpParser\Node\Expr\BinaryOp\BooleanAnd;
|
||||||
use PhpParser\Node\Stmt\If_;
|
use PhpParser\Node\Stmt\If_;
|
||||||
use PhpParser\Node\Stmt\Return_;
|
use PhpParser\Node\Stmt\Return_;
|
||||||
|
use PHPStan\Analyser\Scope;
|
||||||
use Rector\Core\NodeAnalyzer\CallAnalyzer;
|
use Rector\Core\NodeAnalyzer\CallAnalyzer;
|
||||||
use Rector\Core\NodeManipulator\IfManipulator;
|
use Rector\Core\NodeManipulator\IfManipulator;
|
||||||
use Rector\Core\PhpParser\Node\AssignAndBinaryMap;
|
use Rector\Core\PhpParser\Node\AssignAndBinaryMap;
|
||||||
use Rector\Core\Rector\AbstractRector;
|
use Rector\Core\Rector\AbstractScopeAwareRector;
|
||||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||||
/**
|
/**
|
||||||
* @see \Rector\Tests\EarlyReturn\Rector\Return_\ReturnBinaryAndToEarlyReturnRector\ReturnBinaryAndToEarlyReturnRectorTest
|
* @see \Rector\Tests\EarlyReturn\Rector\Return_\ReturnBinaryAndToEarlyReturnRector\ReturnBinaryAndToEarlyReturnRectorTest
|
||||||
*/
|
*/
|
||||||
final class ReturnBinaryAndToEarlyReturnRector extends AbstractRector
|
final class ReturnBinaryAndToEarlyReturnRector extends AbstractScopeAwareRector
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @readonly
|
* @readonly
|
||||||
|
@ -77,7 +78,7 @@ CODE_SAMPLE
|
||||||
* @param Return_ $node
|
* @param Return_ $node
|
||||||
* @return null|Node[]
|
* @return null|Node[]
|
||||||
*/
|
*/
|
||||||
public function refactor(Node $node) : ?array
|
public function refactorWithScope(Node $node, Scope $scope) : ?array
|
||||||
{
|
{
|
||||||
if (!$node->expr instanceof BooleanAnd) {
|
if (!$node->expr instanceof BooleanAnd) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -94,7 +95,7 @@ CODE_SAMPLE
|
||||||
$this->mirrorComments($ifNegations[0], $node);
|
$this->mirrorComments($ifNegations[0], $node);
|
||||||
/** @var BooleanAnd $booleanAnd */
|
/** @var BooleanAnd $booleanAnd */
|
||||||
$booleanAnd = $node->expr;
|
$booleanAnd = $node->expr;
|
||||||
$lastReturnExpr = $this->assignAndBinaryMap->getTruthyExpr($booleanAnd->right);
|
$lastReturnExpr = $this->assignAndBinaryMap->getTruthyExpr($booleanAnd->right, $scope);
|
||||||
return \array_merge($ifNegations, [new Return_($lastReturnExpr)]);
|
return \array_merge($ifNegations, [new Return_($lastReturnExpr)]);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -12,13 +12,13 @@ use PhpParser\Node\Stmt\Return_;
|
||||||
use Rector\Core\NodeAnalyzer\CallAnalyzer;
|
use Rector\Core\NodeAnalyzer\CallAnalyzer;
|
||||||
use Rector\Core\NodeManipulator\IfManipulator;
|
use Rector\Core\NodeManipulator\IfManipulator;
|
||||||
use Rector\Core\PhpParser\Node\AssignAndBinaryMap;
|
use Rector\Core\PhpParser\Node\AssignAndBinaryMap;
|
||||||
use Rector\Core\Rector\AbstractRector;
|
use Rector\Core\Rector\AbstractScopeAwareRector;
|
||||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||||
/**
|
/**
|
||||||
* @see \Rector\Tests\EarlyReturn\Rector\Return_\ReturnBinaryOrToEarlyReturnRector\ReturnBinaryOrToEarlyReturnRectorTest
|
* @see \Rector\Tests\EarlyReturn\Rector\Return_\ReturnBinaryOrToEarlyReturnRector\ReturnBinaryOrToEarlyReturnRectorTest
|
||||||
*/
|
*/
|
||||||
final class ReturnBinaryOrToEarlyReturnRector extends AbstractRector
|
final class ReturnBinaryOrToEarlyReturnRector extends AbstractScopeAwareRector
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @readonly
|
* @readonly
|
||||||
|
@ -77,7 +77,7 @@ CODE_SAMPLE
|
||||||
* @param Return_ $node
|
* @param Return_ $node
|
||||||
* @return null|Node[]
|
* @return null|Node[]
|
||||||
*/
|
*/
|
||||||
public function refactor(Node $node) : ?array
|
public function refactorWithScope(Node $node, \PHPStan\Analyser\Scope $scope) : ?array
|
||||||
{
|
{
|
||||||
if (!$node->expr instanceof BooleanOr) {
|
if (!$node->expr instanceof BooleanOr) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -94,7 +94,7 @@ CODE_SAMPLE
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
$this->mirrorComments($ifs[0], $node);
|
$this->mirrorComments($ifs[0], $node);
|
||||||
$lastReturnExpr = $this->assignAndBinaryMap->getTruthyExpr($booleanOr->right);
|
$lastReturnExpr = $this->assignAndBinaryMap->getTruthyExpr($booleanOr->right, $scope);
|
||||||
return \array_merge($ifs, [new Return_($lastReturnExpr)]);
|
return \array_merge($ifs, [new Return_($lastReturnExpr)]);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -19,12 +19,12 @@ final class VersionResolver
|
||||||
* @api
|
* @api
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public const PACKAGE_VERSION = 'c8f697b16d888505c2bfbbcaba1665402091159b';
|
public const PACKAGE_VERSION = '6156458ef43b1961a0ded5df85ca3fa4c35686e9';
|
||||||
/**
|
/**
|
||||||
* @api
|
* @api
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public const RELEASE_DATE = '2023-05-15 13:00:10';
|
public const RELEASE_DATE = '2023-05-15 22:01:49';
|
||||||
/**
|
/**
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -83,7 +83,7 @@ final class AssignAndBinaryMap
|
||||||
$nodeClass = \get_class($binaryOp);
|
$nodeClass = \get_class($binaryOp);
|
||||||
return self::BINARY_OP_TO_INVERSE_CLASSES[$nodeClass] ?? null;
|
return self::BINARY_OP_TO_INVERSE_CLASSES[$nodeClass] ?? null;
|
||||||
}
|
}
|
||||||
public function getTruthyExpr(Expr $expr) : Expr
|
public function getTruthyExpr(Expr $expr, Scope $scope) : Expr
|
||||||
{
|
{
|
||||||
if ($expr instanceof Bool_) {
|
if ($expr instanceof Bool_) {
|
||||||
return $expr;
|
return $expr;
|
||||||
|
@ -91,10 +91,6 @@ final class AssignAndBinaryMap
|
||||||
if ($expr instanceof BooleanNot) {
|
if ($expr instanceof BooleanNot) {
|
||||||
return $expr;
|
return $expr;
|
||||||
}
|
}
|
||||||
$scope = $expr->getAttribute(AttributeKey::SCOPE);
|
|
||||||
if (!$scope instanceof Scope) {
|
|
||||||
return new Bool_($expr);
|
|
||||||
}
|
|
||||||
$type = $scope->getType($expr);
|
$type = $scope->getType($expr);
|
||||||
if ($type->isBoolean()->yes()) {
|
if ($type->isBoolean()->yes()) {
|
||||||
return $expr;
|
return $expr;
|
||||||
|
|
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';
|
require_once __DIR__ . '/composer/autoload_real.php';
|
||||||
|
|
||||||
return ComposerAutoloaderInitd9c7b52d17fd90a28cff22e2d587297f::getLoader();
|
return ComposerAutoloaderInit25823b7798aa3544f756391be11a39ea::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
|
// autoload_real.php @generated by Composer
|
||||||
|
|
||||||
class ComposerAutoloaderInitd9c7b52d17fd90a28cff22e2d587297f
|
class ComposerAutoloaderInit25823b7798aa3544f756391be11a39ea
|
||||||
{
|
{
|
||||||
private static $loader;
|
private static $loader;
|
||||||
|
|
||||||
|
@ -22,17 +22,17 @@ class ComposerAutoloaderInitd9c7b52d17fd90a28cff22e2d587297f
|
||||||
return self::$loader;
|
return self::$loader;
|
||||||
}
|
}
|
||||||
|
|
||||||
spl_autoload_register(array('ComposerAutoloaderInitd9c7b52d17fd90a28cff22e2d587297f', 'loadClassLoader'), true, true);
|
spl_autoload_register(array('ComposerAutoloaderInit25823b7798aa3544f756391be11a39ea', 'loadClassLoader'), true, true);
|
||||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||||
spl_autoload_unregister(array('ComposerAutoloaderInitd9c7b52d17fd90a28cff22e2d587297f', 'loadClassLoader'));
|
spl_autoload_unregister(array('ComposerAutoloaderInit25823b7798aa3544f756391be11a39ea', 'loadClassLoader'));
|
||||||
|
|
||||||
require __DIR__ . '/autoload_static.php';
|
require __DIR__ . '/autoload_static.php';
|
||||||
call_user_func(\Composer\Autoload\ComposerStaticInitd9c7b52d17fd90a28cff22e2d587297f::getInitializer($loader));
|
call_user_func(\Composer\Autoload\ComposerStaticInit25823b7798aa3544f756391be11a39ea::getInitializer($loader));
|
||||||
|
|
||||||
$loader->setClassMapAuthoritative(true);
|
$loader->setClassMapAuthoritative(true);
|
||||||
$loader->register(true);
|
$loader->register(true);
|
||||||
|
|
||||||
$filesToLoad = \Composer\Autoload\ComposerStaticInitd9c7b52d17fd90a28cff22e2d587297f::$files;
|
$filesToLoad = \Composer\Autoload\ComposerStaticInit25823b7798aa3544f756391be11a39ea::$files;
|
||||||
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
|
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
|
||||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
$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;
|
namespace Composer\Autoload;
|
||||||
|
|
||||||
class ComposerStaticInitd9c7b52d17fd90a28cff22e2d587297f
|
class ComposerStaticInit25823b7798aa3544f756391be11a39ea
|
||||||
{
|
{
|
||||||
public static $files = array (
|
public static $files = array (
|
||||||
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
|
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
|
||||||
|
@ -3101,9 +3101,9 @@ class ComposerStaticInitd9c7b52d17fd90a28cff22e2d587297f
|
||||||
public static function getInitializer(ClassLoader $loader)
|
public static function getInitializer(ClassLoader $loader)
|
||||||
{
|
{
|
||||||
return \Closure::bind(function () use ($loader) {
|
return \Closure::bind(function () use ($loader) {
|
||||||
$loader->prefixLengthsPsr4 = ComposerStaticInitd9c7b52d17fd90a28cff22e2d587297f::$prefixLengthsPsr4;
|
$loader->prefixLengthsPsr4 = ComposerStaticInit25823b7798aa3544f756391be11a39ea::$prefixLengthsPsr4;
|
||||||
$loader->prefixDirsPsr4 = ComposerStaticInitd9c7b52d17fd90a28cff22e2d587297f::$prefixDirsPsr4;
|
$loader->prefixDirsPsr4 = ComposerStaticInit25823b7798aa3544f756391be11a39ea::$prefixDirsPsr4;
|
||||||
$loader->classMap = ComposerStaticInitd9c7b52d17fd90a28cff22e2d587297f::$classMap;
|
$loader->classMap = ComposerStaticInit25823b7798aa3544f756391be11a39ea::$classMap;
|
||||||
|
|
||||||
}, null, ClassLoader::class);
|
}, null, ClassLoader::class);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user