mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-01 00:40:52 +00:00
Updated Rector to commit 4a1880bd2976e3cda6db8b1ca27c44c2c933b9e4
4a1880bd29
[CodeQuality] Add Equal and NotEqual support on SimplifyIfReturnBoolRector (#5697)
This commit is contained in:
parent
95d5fad617
commit
a49cabd869
|
@ -5,7 +5,9 @@ namespace Rector\CodeQuality\Rector\If_;
|
||||||
|
|
||||||
use PhpParser\Node;
|
use PhpParser\Node;
|
||||||
use PhpParser\Node\Expr;
|
use PhpParser\Node\Expr;
|
||||||
|
use PhpParser\Node\Expr\BinaryOp\Equal;
|
||||||
use PhpParser\Node\Expr\BinaryOp\Identical;
|
use PhpParser\Node\Expr\BinaryOp\Identical;
|
||||||
|
use PhpParser\Node\Expr\BinaryOp\NotEqual;
|
||||||
use PhpParser\Node\Expr\BinaryOp\NotIdentical;
|
use PhpParser\Node\Expr\BinaryOp\NotIdentical;
|
||||||
use PhpParser\Node\Expr\BooleanNot;
|
use PhpParser\Node\Expr\BooleanNot;
|
||||||
use PhpParser\Node\Stmt\Else_;
|
use PhpParser\Node\Stmt\Else_;
|
||||||
|
@ -140,7 +142,7 @@ CODE_SAMPLE
|
||||||
if (\strpos($condString, '!=') === \false) {
|
if (\strpos($condString, '!=') === \false) {
|
||||||
return !$this->valueResolver->isTrueOrFalse($return->expr);
|
return !$this->valueResolver->isTrueOrFalse($return->expr);
|
||||||
}
|
}
|
||||||
return !$if->cond instanceof NotIdentical;
|
return !$if->cond instanceof NotIdentical && !$if->cond instanceof NotEqual;
|
||||||
}
|
}
|
||||||
private function processReturnTrue(If_ $if, Return_ $nextReturn) : Return_
|
private function processReturnTrue(If_ $if, Return_ $nextReturn) : Return_
|
||||||
{
|
{
|
||||||
|
@ -155,6 +157,10 @@ CODE_SAMPLE
|
||||||
$notIdentical = new NotIdentical($if->cond->left, $if->cond->right);
|
$notIdentical = new NotIdentical($if->cond->left, $if->cond->right);
|
||||||
return new Return_($this->exprBoolCaster->boolCastOrNullCompareIfNeeded($notIdentical));
|
return new Return_($this->exprBoolCaster->boolCastOrNullCompareIfNeeded($notIdentical));
|
||||||
}
|
}
|
||||||
|
if ($if->cond instanceof Equal) {
|
||||||
|
$notIdentical = new NotEqual($if->cond->left, $if->cond->right);
|
||||||
|
return new Return_($this->exprBoolCaster->boolCastOrNullCompareIfNeeded($notIdentical));
|
||||||
|
}
|
||||||
if (!$nextReturn->expr instanceof Expr) {
|
if (!$nextReturn->expr instanceof Expr) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -207,6 +213,10 @@ CODE_SAMPLE
|
||||||
$if->cond = new Identical($if->cond->left, $if->cond->right);
|
$if->cond = new Identical($if->cond->left, $if->cond->right);
|
||||||
return $this->processReturnTrue($if, $return);
|
return $this->processReturnTrue($if, $return);
|
||||||
}
|
}
|
||||||
|
if ($if->cond instanceof NotEqual && $this->valueResolver->isTrue($expr)) {
|
||||||
|
$if->cond = new Equal($if->cond->left, $if->cond->right);
|
||||||
|
return $this->processReturnTrue($if, $return);
|
||||||
|
}
|
||||||
return $this->processReturnFalse($if, $return);
|
return $this->processReturnFalse($if, $return);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -19,12 +19,12 @@ final class VersionResolver
|
||||||
* @api
|
* @api
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public const PACKAGE_VERSION = '750713625e27e07175e4c7144802fb623422c036';
|
public const PACKAGE_VERSION = '4a1880bd2976e3cda6db8b1ca27c44c2c933b9e4';
|
||||||
/**
|
/**
|
||||||
* @api
|
* @api
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public const RELEASE_DATE = '2024-03-06 20:53:31';
|
public const RELEASE_DATE = '2024-03-07 20:44:22';
|
||||||
/**
|
/**
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
|
|
8
vendor/composer/installed.json
vendored
8
vendor/composer/installed.json
vendored
|
@ -1679,12 +1679,12 @@
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https:\/\/github.com\/rectorphp\/rector-doctrine.git",
|
"url": "https:\/\/github.com\/rectorphp\/rector-doctrine.git",
|
||||||
"reference": "a99d22cbfa069db1d23391bae3171659510bbbee"
|
"reference": "b45a62ee19d9c3cdcc1c03815957dfadf80687cd"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-doctrine\/zipball\/a99d22cbfa069db1d23391bae3171659510bbbee",
|
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-doctrine\/zipball\/b45a62ee19d9c3cdcc1c03815957dfadf80687cd",
|
||||||
"reference": "a99d22cbfa069db1d23391bae3171659510bbbee",
|
"reference": "b45a62ee19d9c3cdcc1c03815957dfadf80687cd",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -1709,7 +1709,7 @@
|
||||||
"tomasvotruba\/unused-public": "^0.3",
|
"tomasvotruba\/unused-public": "^0.3",
|
||||||
"tracy\/tracy": "^2.10"
|
"tracy\/tracy": "^2.10"
|
||||||
},
|
},
|
||||||
"time": "2024-03-07T12:08:53+00:00",
|
"time": "2024-03-07T12:44:28+00:00",
|
||||||
"default-branch": true,
|
"default-branch": true,
|
||||||
"type": "rector-extension",
|
"type": "rector-extension",
|
||||||
"extra": {
|
"extra": {
|
||||||
|
|
2
vendor/composer/installed.php
vendored
2
vendor/composer/installed.php
vendored
File diff suppressed because one or more lines are too long
|
@ -9,7 +9,7 @@ namespace Rector\RectorInstaller;
|
||||||
*/
|
*/
|
||||||
final class GeneratedConfig
|
final class GeneratedConfig
|
||||||
{
|
{
|
||||||
public const EXTENSIONS = array('rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => NULL, 'version' => 'dev-main a99d22c'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => NULL, 'version' => 'dev-main 68e0635'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => NULL, 'version' => 'dev-main e065c40'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => NULL, 'version' => 'dev-main 5ce789d'));
|
public const EXTENSIONS = array('rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => NULL, 'version' => 'dev-main b45a62e'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => NULL, 'version' => 'dev-main 68e0635'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => NULL, 'version' => 'dev-main e065c40'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => NULL, 'version' => 'dev-main 5ce789d'));
|
||||||
private function __construct()
|
private function __construct()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user