From 241f8a9ce1d19a0dc10149269ce9a4cd588eeb0c Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Mon, 23 Aug 2021 07:28:19 +0700 Subject: [PATCH] [Php71] Ensure count() function parameter exists early (#742) --- rules/Php71/Rector/FuncCall/CountOnNullRector.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rules/Php71/Rector/FuncCall/CountOnNullRector.php b/rules/Php71/Rector/FuncCall/CountOnNullRector.php index 8423097c025..446c145b226 100644 --- a/rules/Php71/Rector/FuncCall/CountOnNullRector.php +++ b/rules/Php71/Rector/FuncCall/CountOnNullRector.php @@ -133,6 +133,10 @@ private function shouldSkip(FuncCall $funcCall): bool return true; } + if (! isset($funcCall->args[0])) { + return true; + } + if ($funcCall->args[0]->value instanceof ClassConstFetch) { return true; } @@ -149,10 +153,6 @@ private function shouldSkip(FuncCall $funcCall): bool return true; } - if (! isset($funcCall->args[0])) { - return true; - } - // skip node in trait, as impossible to analyse $classLike = $funcCall->getAttribute(AttributeKey::CLASS_NODE); return $classLike instanceof Trait_;