From e3e6cff9bd98bbeb146d642da7f887d8602f8ad3 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Tue, 12 Dec 2023 15:47:12 +0000 Subject: [PATCH] Updated Rector to commit fea5d6c0034746e050851887a7900bf94a22069d https://github.com/rectorphp/rector-src/commit/fea5d6c0034746e050851887a7900bf94a22069d [TypeDeclaration] Skip casted to (array) on StrictArrayParamDimFetchRector (#5356) --- .../ClassMethod/StrictArrayParamDimFetchRector.php | 10 +++++++++- src/Application/VersionResolver.php | 4 ++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/rules/TypeDeclaration/Rector/ClassMethod/StrictArrayParamDimFetchRector.php b/rules/TypeDeclaration/Rector/ClassMethod/StrictArrayParamDimFetchRector.php index 1632bb368e7..58beb0a3cda 100644 --- a/rules/TypeDeclaration/Rector/ClassMethod/StrictArrayParamDimFetchRector.php +++ b/rules/TypeDeclaration/Rector/ClassMethod/StrictArrayParamDimFetchRector.php @@ -8,6 +8,7 @@ use PhpParser\Node\Expr; use PhpParser\Node\Expr\ArrayDimFetch; use PhpParser\Node\Expr\AssignOp\Coalesce as AssignOpCoalesce; use PhpParser\Node\Expr\BinaryOp\Coalesce; +use PhpParser\Node\Expr\Cast\Array_; use PhpParser\Node\Expr\Closure; use PhpParser\Node\Expr\FuncCall; use PhpParser\Node\Expr\MethodCall; @@ -167,7 +168,14 @@ CODE_SAMPLE if ($nodeToCheck instanceof Variable && $this->isName($nodeToCheck, $paramName)) { return \true; } - return $this->isEchoed($node, $paramName); + return $this->isEchoedOrCasted($node, $paramName); + } + private function isEchoedOrCasted(Node $node, string $paramName) : bool + { + if ($this->isEchoed($node, $paramName)) { + return \true; + } + return $node instanceof Array_ && $node->expr instanceof Variable && $node->expr->name === $paramName; } private function isMethodCallOrArrayDimFetch(string $paramName, ?Node $node) : bool { diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index e246252819e..35c8e81008e 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 = 'dc9573d9bd60ec966db626be91c13cc6a5c4bbef'; + public const PACKAGE_VERSION = 'fea5d6c0034746e050851887a7900bf94a22069d'; /** * @api * @var string */ - public const RELEASE_DATE = '2023-12-11 14:04:32'; + public const RELEASE_DATE = '2023-12-12 22:44:49'; /** * @var int */