From e757a47a7abd6891a438bc00053484122b23410d Mon Sep 17 00:00:00 2001 From: Payton Swick Date: Fri, 9 Dec 2022 18:16:53 -0500 Subject: [PATCH 1/2] Add explicit types for 'nested_parenthesis' --- VariableAnalysis/Lib/Helpers.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/VariableAnalysis/Lib/Helpers.php b/VariableAnalysis/Lib/Helpers.php index 9b03bcd..b34b3ce 100644 --- a/VariableAnalysis/Lib/Helpers.php +++ b/VariableAnalysis/Lib/Helpers.php @@ -69,6 +69,9 @@ public static function findContainingOpeningBracket(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); if (isset($tokens[$stackPtr]['nested_parenthesis'])) { + /** + * @var array + */ $openPtrs = array_keys($tokens[$stackPtr]['nested_parenthesis']); return (int)end($openPtrs); } @@ -1081,6 +1084,9 @@ public static function getFunctionIndexForFunctionCallArgument(File $phpcsFile, if (empty($token['nested_parenthesis'])) { return null; } + /** + * @var array + */ $startingParenthesis = array_keys($token['nested_parenthesis']); $startOfArguments = end($startingParenthesis); if (! is_int($startOfArguments)) { From 1e403583591a478a340f1d6788d0731ad65d5b24 Mon Sep 17 00:00:00 2001 From: Payton Swick Date: Fri, 9 Dec 2022 18:24:19 -0500 Subject: [PATCH 2/2] Also allow string --- VariableAnalysis/Lib/Helpers.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/VariableAnalysis/Lib/Helpers.php b/VariableAnalysis/Lib/Helpers.php index b34b3ce..b05917e 100644 --- a/VariableAnalysis/Lib/Helpers.php +++ b/VariableAnalysis/Lib/Helpers.php @@ -70,8 +70,8 @@ public static function findContainingOpeningBracket(File $phpcsFile, $stackPtr) $tokens = $phpcsFile->getTokens(); if (isset($tokens[$stackPtr]['nested_parenthesis'])) { /** - * @var array - */ + * @var array + */ $openPtrs = array_keys($tokens[$stackPtr]['nested_parenthesis']); return (int)end($openPtrs); } @@ -1085,7 +1085,7 @@ public static function getFunctionIndexForFunctionCallArgument(File $phpcsFile, return null; } /** - * @var array + * @var array */ $startingParenthesis = array_keys($token['nested_parenthesis']); $startOfArguments = end($startingParenthesis);