Updated Rector to commit 502d0ad3805984c4e3c0a8c6636c1174068169fc

502d0ad380 [DeadCode] Handle assign in If_ cond on RemoveUnusedNonEmptyArrayBeforeForeachRector (#2734)
This commit is contained in:
Tomas Votruba 2022-08-05 09:27:15 +00:00
parent 80bfee9246
commit ac89ac3559
15 changed files with 66 additions and 74 deletions

View File

@ -4,7 +4,10 @@ declare (strict_types=1);
namespace Rector\DeadCode\Rector\If_;
use PhpParser\Node;
use PhpParser\Node\Expr\Assign;
use PhpParser\Node\Expr\Variable;
use PhpParser\Node\Stmt;
use PhpParser\Node\Stmt\Expression;
use PhpParser\Node\Stmt\Foreach_;
use PhpParser\Node\Stmt\If_;
use PHPStan\Type\ArrayType;
@ -87,13 +90,18 @@ CODE_SAMPLE
}
/**
* @param If_ $node
* @return Stmt[]|Foreach_|null
*/
public function refactor(Node $node) : ?Node
public function refactor(Node $node)
{
if (!$this->isUselessBeforeForeachCheck($node)) {
return null;
}
/** @var Foreach_ $stmt */
$stmt = $node->stmts[0];
if ($node->cond instanceof Assign && $this->nodeComparator->areNodesEqual($node->cond->var, $stmt->expr)) {
return [new Expression($node->cond), $stmt];
}
$ifComments = $node->getAttribute(AttributeKey::COMMENTS) ?? [];
$stmtComments = $stmt->getAttribute(AttributeKey::COMMENTS) ?? [];
$comments = \array_merge($ifComments, $stmtComments);

View File

@ -17,12 +17,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '685dc702a0dc6c8490bf1d9c39f8a8072e4333f0';
public const PACKAGE_VERSION = '502d0ad3805984c4e3c0a8c6636c1174068169fc';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2022-08-04 21:13:37';
public const RELEASE_DATE = '2022-08-05 11:22:38';
/**
* @var int
*/

2
vendor/autoload.php vendored
View File

@ -9,4 +9,4 @@ if (PHP_VERSION_ID < 50600) {
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit289e376139a46b2f1bc5ca117a565b00::getLoader();
return ComposerAutoloaderInit4a3330273c29fc2825dba6460d7e2dbd::getLoader();

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit289e376139a46b2f1bc5ca117a565b00
class ComposerAutoloaderInit4a3330273c29fc2825dba6460d7e2dbd
{
private static $loader;
@ -22,19 +22,19 @@ class ComposerAutoloaderInit289e376139a46b2f1bc5ca117a565b00
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit289e376139a46b2f1bc5ca117a565b00', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit4a3330273c29fc2825dba6460d7e2dbd', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInit289e376139a46b2f1bc5ca117a565b00', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit4a3330273c29fc2825dba6460d7e2dbd', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit289e376139a46b2f1bc5ca117a565b00::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit4a3330273c29fc2825dba6460d7e2dbd::getInitializer($loader));
$loader->setClassMapAuthoritative(true);
$loader->register(true);
$includeFiles = \Composer\Autoload\ComposerStaticInit289e376139a46b2f1bc5ca117a565b00::$files;
$includeFiles = \Composer\Autoload\ComposerStaticInit4a3330273c29fc2825dba6460d7e2dbd::$files;
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequire289e376139a46b2f1bc5ca117a565b00($fileIdentifier, $file);
composerRequire4a3330273c29fc2825dba6460d7e2dbd($fileIdentifier, $file);
}
return $loader;
@ -46,7 +46,7 @@ class ComposerAutoloaderInit289e376139a46b2f1bc5ca117a565b00
* @param string $file
* @return void
*/
function composerRequire289e376139a46b2f1bc5ca117a565b00($fileIdentifier, $file)
function composerRequire4a3330273c29fc2825dba6460d7e2dbd($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;

View File

@ -4,7 +4,7 @@
namespace Composer\Autoload;
class ComposerStaticInit289e376139a46b2f1bc5ca117a565b00
class ComposerStaticInit4a3330273c29fc2825dba6460d7e2dbd
{
public static $files = array (
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
@ -3407,9 +3407,9 @@ class ComposerStaticInit289e376139a46b2f1bc5ca117a565b00
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit289e376139a46b2f1bc5ca117a565b00::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit289e376139a46b2f1bc5ca117a565b00::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit289e376139a46b2f1bc5ca117a565b00::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit4a3330273c29fc2825dba6460d7e2dbd::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit4a3330273c29fc2825dba6460d7e2dbd::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit4a3330273c29fc2825dba6460d7e2dbd::$classMap;
}, null, ClassLoader::class);
}

View File

@ -3329,12 +3329,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/symplify\/astral.git",
"reference": "33a08a637ff39b5014785f089c4e9f0be109c19f"
"reference": "93943dee164859b80bc86acb2f786dcabcd34816"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/symplify\/astral\/zipball\/33a08a637ff39b5014785f089c4e9f0be109c19f",
"reference": "33a08a637ff39b5014785f089c4e9f0be109c19f",
"url": "https:\/\/api.github.com\/repos\/symplify\/astral\/zipball\/93943dee164859b80bc86acb2f786dcabcd34816",
"reference": "93943dee164859b80bc86acb2f786dcabcd34816",
"shasum": ""
},
"require": {
@ -3359,7 +3359,6 @@
"symplify\/easy-parallel": "<11.0.9",
"symplify\/easy-testing": "<11.0.9",
"symplify\/monorepo-builder": "<11.0.9",
"symplify\/neon-config-dumper": "<11.0.9",
"symplify\/php-config-printer": "<11.0.9",
"symplify\/phpstan-extensions": "<11.0.9",
"symplify\/phpstan-rules": "<11.0.9",
@ -3375,7 +3374,7 @@
"phpunit\/phpunit": "^9.5.21",
"symplify\/easy-testing": "^11.1"
},
"time": "2022-07-28T17:44:48+00:00",
"time": "2022-08-04T20:17:32+00:00",
"default-branch": true,
"type": "phpstan-extension",
"extra": {
@ -3421,12 +3420,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/symplify\/autowire-array-parameter.git",
"reference": "d45706eb2c26220a23d55ea0fb8a506cdc5f261e"
"reference": "78b0c28be61568fc3d0998da6366a4d3bbd221ae"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/symplify\/autowire-array-parameter\/zipball\/d45706eb2c26220a23d55ea0fb8a506cdc5f261e",
"reference": "d45706eb2c26220a23d55ea0fb8a506cdc5f261e",
"url": "https:\/\/api.github.com\/repos\/symplify\/autowire-array-parameter\/zipball\/78b0c28be61568fc3d0998da6366a4d3bbd221ae",
"reference": "78b0c28be61568fc3d0998da6366a4d3bbd221ae",
"shasum": ""
},
"require": {
@ -3445,7 +3444,6 @@
"symplify\/easy-parallel": "<11.0.9",
"symplify\/easy-testing": "<11.0.9",
"symplify\/monorepo-builder": "<11.0.9",
"symplify\/neon-config-dumper": "<11.0.9",
"symplify\/php-config-printer": "<11.0.9",
"symplify\/phpstan-extensions": "<11.0.9",
"symplify\/phpstan-rules": "<11.0.9",
@ -3460,7 +3458,7 @@
"require-dev": {
"phpunit\/phpunit": "^9.5.21"
},
"time": "2022-07-28T17:44:50+00:00",
"time": "2022-08-04T20:17:17+00:00",
"default-branch": true,
"type": "library",
"extra": {
@ -3501,12 +3499,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/symplify\/composer-json-manipulator.git",
"reference": "3844a9e2b0e81c0a1617b7ecd64733b79dd9e383"
"reference": "3a0098651baed2d0a0e4f50807294140fbe16b0a"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/symplify\/composer-json-manipulator\/zipball\/3844a9e2b0e81c0a1617b7ecd64733b79dd9e383",
"reference": "3844a9e2b0e81c0a1617b7ecd64733b79dd9e383",
"url": "https:\/\/api.github.com\/repos\/symplify\/composer-json-manipulator\/zipball\/3a0098651baed2d0a0e4f50807294140fbe16b0a",
"reference": "3a0098651baed2d0a0e4f50807294140fbe16b0a",
"shasum": ""
},
"require": {
@ -3529,7 +3527,6 @@
"symplify\/easy-parallel": "<11.0.9",
"symplify\/easy-testing": "<11.0.9",
"symplify\/monorepo-builder": "<11.0.9",
"symplify\/neon-config-dumper": "<11.0.9",
"symplify\/php-config-printer": "<11.0.9",
"symplify\/phpstan-extensions": "<11.0.9",
"symplify\/phpstan-rules": "<11.0.9",
@ -3543,7 +3540,7 @@
"require-dev": {
"phpunit\/phpunit": "^9.5.21"
},
"time": "2022-07-28T17:44:50+00:00",
"time": "2022-08-04T20:17:21+00:00",
"default-branch": true,
"type": "symfony-bundle",
"extra": {
@ -3657,12 +3654,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/symplify\/easy-testing.git",
"reference": "6c9a4f36253a0c261fdec9eaa2d6d4a1388653a9"
"reference": "cd057d7a81ae40d29ee6a55049da5f3a0eabbd33"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/symplify\/easy-testing\/zipball\/6c9a4f36253a0c261fdec9eaa2d6d4a1388653a9",
"reference": "6c9a4f36253a0c261fdec9eaa2d6d4a1388653a9",
"url": "https:\/\/api.github.com\/repos\/symplify\/easy-testing\/zipball\/cd057d7a81ae40d29ee6a55049da5f3a0eabbd33",
"reference": "cd057d7a81ae40d29ee6a55049da5f3a0eabbd33",
"shasum": ""
},
"require": {
@ -3685,7 +3682,6 @@
"symplify\/easy-coding-standard": "<11.0.9",
"symplify\/easy-parallel": "<11.0.9",
"symplify\/monorepo-builder": "<11.0.9",
"symplify\/neon-config-dumper": "<11.0.9",
"symplify\/php-config-printer": "<11.0.9",
"symplify\/phpstan-extensions": "<11.0.9",
"symplify\/phpstan-rules": "<11.0.9",
@ -3698,7 +3694,7 @@
"require-dev": {
"phpunit\/phpunit": "^9.5.21"
},
"time": "2022-08-04T17:04:44+00:00",
"time": "2022-08-04T20:17:23+00:00",
"default-branch": true,
"bin": [
"bin\/easy-testing"
@ -3742,12 +3738,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/symplify\/package-builder.git",
"reference": "0341c62d9cda02c00f219c740539250a70339bd0"
"reference": "b71e3772581abf804711fc5457cd11180cd328b9"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/symplify\/package-builder\/zipball\/0341c62d9cda02c00f219c740539250a70339bd0",
"reference": "0341c62d9cda02c00f219c740539250a70339bd0",
"url": "https:\/\/api.github.com\/repos\/symplify\/package-builder\/zipball\/b71e3772581abf804711fc5457cd11180cd328b9",
"reference": "b71e3772581abf804711fc5457cd11180cd328b9",
"shasum": ""
},
"require": {
@ -3771,7 +3767,6 @@
"symplify\/easy-coding-standard": "<11.0.9",
"symplify\/easy-parallel": "<11.0.9",
"symplify\/monorepo-builder": "<11.0.9",
"symplify\/neon-config-dumper": "<11.0.9",
"symplify\/php-config-printer": "<11.0.9",
"symplify\/phpstan-extensions": "<11.0.9",
"symplify\/phpstan-rules": "<11.0.9",
@ -3785,7 +3780,7 @@
"require-dev": {
"phpunit\/phpunit": "^9.5.21"
},
"time": "2022-07-28T17:45:02+00:00",
"time": "2022-08-04T20:17:19+00:00",
"default-branch": true,
"type": "library",
"extra": {
@ -3826,12 +3821,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/symplify\/rule-doc-generator-contracts.git",
"reference": "3e57d1c3efbf8eb257fb06e635fe377a59fefcb4"
"reference": "e49ad97c63ddd62cba6b8f8b4d8d66847bf08cba"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/symplify\/rule-doc-generator-contracts\/zipball\/3e57d1c3efbf8eb257fb06e635fe377a59fefcb4",
"reference": "3e57d1c3efbf8eb257fb06e635fe377a59fefcb4",
"url": "https:\/\/api.github.com\/repos\/symplify\/rule-doc-generator-contracts\/zipball\/e49ad97c63ddd62cba6b8f8b4d8d66847bf08cba",
"reference": "e49ad97c63ddd62cba6b8f8b4d8d66847bf08cba",
"shasum": ""
},
"require": {
@ -3849,7 +3844,6 @@
"symplify\/easy-parallel": "<11.0.9",
"symplify\/easy-testing": "<11.0.9",
"symplify\/monorepo-builder": "<11.0.9",
"symplify\/neon-config-dumper": "<11.0.9",
"symplify\/package-builder": "<11.0.9",
"symplify\/php-config-printer": "<11.0.9",
"symplify\/phpstan-extensions": "<11.0.9",
@ -3861,7 +3855,7 @@
"symplify\/symplify-kernel": "<11.0.9",
"symplify\/vendor-patches": "<11.0.9"
},
"time": "2022-07-28T17:43:44+00:00",
"time": "2022-08-04T20:17:26+00:00",
"default-branch": true,
"type": "library",
"extra": {
@ -3881,7 +3875,7 @@
],
"description": "Contracts for production code of RuleDocGenerator",
"support": {
"source": "https:\/\/github.com\/symplify\/rule-doc-generator-contracts\/tree\/11.0.9"
"source": "https:\/\/github.com\/symplify\/rule-doc-generator-contracts\/tree\/main"
},
"funding": [
{
@ -3984,12 +3978,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/symplify\/smart-file-system.git",
"reference": "c2b9abcbcd49289a7bcc1f6bd2571a4719f225fc"
"reference": "30697befdf353b21a93b0681b955b9e54379f7bc"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/symplify\/smart-file-system\/zipball\/c2b9abcbcd49289a7bcc1f6bd2571a4719f225fc",
"reference": "c2b9abcbcd49289a7bcc1f6bd2571a4719f225fc",
"url": "https:\/\/api.github.com\/repos\/symplify\/smart-file-system\/zipball\/30697befdf353b21a93b0681b955b9e54379f7bc",
"reference": "30697befdf353b21a93b0681b955b9e54379f7bc",
"shasum": ""
},
"require": {
@ -4009,7 +4003,6 @@
"symplify\/easy-parallel": "<11.0.9",
"symplify\/easy-testing": "<11.0.9",
"symplify\/monorepo-builder": "<11.0.9",
"symplify\/neon-config-dumper": "<11.0.9",
"symplify\/package-builder": "<11.0.9",
"symplify\/php-config-printer": "<11.0.9",
"symplify\/phpstan-extensions": "<11.0.9",
@ -4025,7 +4018,7 @@
"nette\/finder": "^2.5.3",
"phpunit\/phpunit": "^9.5.21"
},
"time": "2022-07-28T17:43:53+00:00",
"time": "2022-08-04T20:17:40+00:00",
"default-branch": true,
"type": "library",
"extra": {
@ -4045,7 +4038,7 @@
],
"description": "Sanitized FileInfo with safe getRealPath() and other handy methods",
"support": {
"source": "https:\/\/github.com\/symplify\/smart-file-system\/tree\/11.0.9"
"source": "https:\/\/github.com\/symplify\/smart-file-system\/tree\/main"
},
"funding": [
{
@ -4066,12 +4059,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/symplify\/symplify-kernel.git",
"reference": "1b8618c8cabcc4d20d52e4d53b7ad8e22fde4dbb"
"reference": "d13b22a1c59b9959460f76e5805eb40c5fc8ee89"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/symplify\/symplify-kernel\/zipball\/1b8618c8cabcc4d20d52e4d53b7ad8e22fde4dbb",
"reference": "1b8618c8cabcc4d20d52e4d53b7ad8e22fde4dbb",
"url": "https:\/\/api.github.com\/repos\/symplify\/symplify-kernel\/zipball\/d13b22a1c59b9959460f76e5805eb40c5fc8ee89",
"reference": "d13b22a1c59b9959460f76e5805eb40c5fc8ee89",
"shasum": ""
},
"require": {
@ -4093,7 +4086,6 @@
"symplify\/easy-parallel": "<11.0.9",
"symplify\/easy-testing": "<11.0.9",
"symplify\/monorepo-builder": "<11.0.9",
"symplify\/neon-config-dumper": "<11.0.9",
"symplify\/php-config-printer": "<11.0.9",
"symplify\/phpstan-extensions": "<11.0.9",
"symplify\/phpstan-rules": "<11.0.9",
@ -4106,7 +4098,7 @@
"require-dev": {
"phpunit\/phpunit": "^9.5.21"
},
"time": "2022-07-28T17:45:16+00:00",
"time": "2022-08-04T20:17:51+00:00",
"default-branch": true,
"type": "library",
"extra": {

File diff suppressed because one or more lines are too long

View File

@ -58,8 +58,7 @@
"symplify\/easy-ci": "<11.0.9",
"symplify\/coding-standard": "<11.0.9",
"symplify\/autowire-array-parameter": "<11.0.9",
"symplify\/easy-parallel": "<11.0.9",
"symplify\/neon-config-dumper": "<11.0.9"
"symplify\/easy-parallel": "<11.0.9"
},
"minimum-stability": "dev",
"prefer-stable": true

View File

@ -45,8 +45,7 @@
"symplify\/config-transformer": "<11.0.9",
"symplify\/easy-ci": "<11.0.9",
"symplify\/coding-standard": "<11.0.9",
"symplify\/easy-parallel": "<11.0.9",
"symplify\/neon-config-dumper": "<11.0.9"
"symplify\/easy-parallel": "<11.0.9"
},
"minimum-stability": "dev",
"prefer-stable": true

View File

@ -49,8 +49,7 @@
"symplify\/config-transformer": "<11.0.9",
"symplify\/easy-ci": "<11.0.9",
"symplify\/coding-standard": "<11.0.9",
"symplify\/easy-parallel": "<11.0.9",
"symplify\/neon-config-dumper": "<11.0.9"
"symplify\/easy-parallel": "<11.0.9"
},
"minimum-stability": "dev",
"prefer-stable": true

View File

@ -51,8 +51,7 @@
"symplify\/config-transformer": "<11.0.9",
"symplify\/easy-ci": "<11.0.9",
"symplify\/coding-standard": "<11.0.9",
"symplify\/easy-parallel": "<11.0.9",
"symplify\/neon-config-dumper": "<11.0.9"
"symplify\/easy-parallel": "<11.0.9"
},
"minimum-stability": "dev",
"prefer-stable": true

View File

@ -49,8 +49,7 @@
"symplify\/config-transformer": "<11.0.9",
"symplify\/easy-ci": "<11.0.9",
"symplify\/coding-standard": "<11.0.9",
"symplify\/easy-parallel": "<11.0.9",
"symplify\/neon-config-dumper": "<11.0.9"
"symplify\/easy-parallel": "<11.0.9"
},
"minimum-stability": "dev",
"prefer-stable": true

View File

@ -36,8 +36,7 @@
"symplify\/config-transformer": "<11.0.9",
"symplify\/easy-ci": "<11.0.9",
"symplify\/coding-standard": "<11.0.9",
"symplify\/easy-parallel": "<11.0.9",
"symplify\/neon-config-dumper": "<11.0.9"
"symplify\/easy-parallel": "<11.0.9"
},
"minimum-stability": "dev",
"prefer-stable": true

View File

@ -47,8 +47,7 @@
"symplify\/config-transformer": "<11.0.9",
"symplify\/easy-ci": "<11.0.9",
"symplify\/coding-standard": "<11.0.9",
"symplify\/easy-parallel": "<11.0.9",
"symplify\/neon-config-dumper": "<11.0.9"
"symplify\/easy-parallel": "<11.0.9"
},
"minimum-stability": "dev",
"prefer-stable": true

View File

@ -46,8 +46,7 @@
"symplify\/config-transformer": "<11.0.9",
"symplify\/easy-ci": "<11.0.9",
"symplify\/coding-standard": "<11.0.9",
"symplify\/easy-parallel": "<11.0.9",
"symplify\/neon-config-dumper": "<11.0.9"
"symplify\/easy-parallel": "<11.0.9"
},
"minimum-stability": "dev",
"prefer-stable": true