From 4c4ad160ddcab9dc8d7e34a516c3ed6eaf875d24 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Sat, 14 Oct 2023 12:51:53 +0000 Subject: [PATCH] Updated Rector to commit c639ef8ad9213881d4fe08554f090934bc5dda07 https://github.com/rectorphp/rector-src/commit/c639ef8ad9213881d4fe08554f090934bc5dda07 RemoveUnusedNonEmptyArrayBeforeForeachRector: ignore phpdoc types (#5169) --- .../If_/RemoveUnusedNonEmptyArrayBeforeForeachRector.php | 6 +++++- src/Application/VersionResolver.php | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/rules/DeadCode/Rector/If_/RemoveUnusedNonEmptyArrayBeforeForeachRector.php b/rules/DeadCode/Rector/If_/RemoveUnusedNonEmptyArrayBeforeForeachRector.php index be7600c8179..a1bad27e2fc 100644 --- a/rules/DeadCode/Rector/If_/RemoveUnusedNonEmptyArrayBeforeForeachRector.php +++ b/rules/DeadCode/Rector/If_/RemoveUnusedNonEmptyArrayBeforeForeachRector.php @@ -120,13 +120,17 @@ CODE_SAMPLE if (\is_string($variableName) && $this->reservedKeywordAnalyzer->isNativeVariable($variableName)) { return \false; } + $ifType = $scope->getNativeType($foreachExpr); + if (!$ifType->isArray()->yes()) { + return \false; + } } $ifCond = $if->cond; if ($ifCond instanceof BooleanAnd) { return $this->isUselessBooleanAnd($ifCond, $foreachExpr); } if (($ifCond instanceof Variable || $this->propertyFetchAnalyzer->isPropertyFetch($ifCond)) && $this->nodeComparator->areNodesEqual($ifCond, $foreachExpr)) { - $ifType = $scope->getType($ifCond); + $ifType = $scope->getNativeType($ifCond); return $ifType->isArray()->yes(); } if ($this->uselessIfCondBeforeForeachDetector->isMatchingNotIdenticalEmptyArray($if, $foreachExpr)) { diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index fcc3be9d8b9..40d38f2374f 100644 --- a/src/Application/VersionResolver.php +++ b/src/Application/VersionResolver.php @@ -19,12 +19,12 @@ final class VersionResolver * @api * @var string */ - public const PACKAGE_VERSION = 'd55a35bcdede830d3927de1c11e0f7f0d12ee9e4'; + public const PACKAGE_VERSION = 'c639ef8ad9213881d4fe08554f090934bc5dda07'; /** * @api * @var string */ - public const RELEASE_DATE = '2023-10-13 22:53:35'; + public const RELEASE_DATE = '2023-10-14 19:48:51'; /** * @var int */