Updated Rector to commit 4a1880bd2976e3cda6db8b1ca27c44c2c933b9e4

4a1880bd29 [CodeQuality] Add Equal and NotEqual support on SimplifyIfReturnBoolRector (#5697)
This commit is contained in:
Tomas Votruba 2024-03-07 13:46:36 +00:00
parent 95d5fad617
commit a49cabd869
5 changed files with 19 additions and 9 deletions

View File

@ -5,7 +5,9 @@ namespace Rector\CodeQuality\Rector\If_;
use PhpParser\Node;
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\BinaryOp\Equal;
use PhpParser\Node\Expr\BinaryOp\Identical;
use PhpParser\Node\Expr\BinaryOp\NotEqual;
use PhpParser\Node\Expr\BinaryOp\NotIdentical;
use PhpParser\Node\Expr\BooleanNot;
use PhpParser\Node\Stmt\Else_;
@ -140,7 +142,7 @@ CODE_SAMPLE
if (\strpos($condString, '!=') === \false) {
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_
{
@ -155,6 +157,10 @@ CODE_SAMPLE
$notIdentical = new NotIdentical($if->cond->left, $if->cond->right);
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) {
return null;
}
@ -207,6 +213,10 @@ CODE_SAMPLE
$if->cond = new Identical($if->cond->left, $if->cond->right);
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 null;

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '750713625e27e07175e4c7144802fb623422c036';
public const PACKAGE_VERSION = '4a1880bd2976e3cda6db8b1ca27c44c2c933b9e4';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2024-03-06 20:53:31';
public const RELEASE_DATE = '2024-03-07 20:44:22';
/**
* @var int
*/

View File

@ -1679,12 +1679,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-doctrine.git",
"reference": "a99d22cbfa069db1d23391bae3171659510bbbee"
"reference": "b45a62ee19d9c3cdcc1c03815957dfadf80687cd"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-doctrine\/zipball\/a99d22cbfa069db1d23391bae3171659510bbbee",
"reference": "a99d22cbfa069db1d23391bae3171659510bbbee",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-doctrine\/zipball\/b45a62ee19d9c3cdcc1c03815957dfadf80687cd",
"reference": "b45a62ee19d9c3cdcc1c03815957dfadf80687cd",
"shasum": ""
},
"require": {
@ -1709,7 +1709,7 @@
"tomasvotruba\/unused-public": "^0.3",
"tracy\/tracy": "^2.10"
},
"time": "2024-03-07T12:08:53+00:00",
"time": "2024-03-07T12:44:28+00:00",
"default-branch": true,
"type": "rector-extension",
"extra": {

File diff suppressed because one or more lines are too long

View File

@ -9,7 +9,7 @@ namespace Rector\RectorInstaller;
*/
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()
{
}