Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,15 @@ function method_with_self_inside_closure() {
echo static::$static_member;
}
}

function function_with_type_argument_in_closure($items, $item_id) {
return array_filter($items, function (Taxed_Line_Item $line_item) use ($item_id) {
return $line_item->item_id === $item_id;
});
}

function function_with_fully_qualified_type_argument_in_closure($items, $item_id) {
return array_filter($items, function (\Taxed_Line_Item $line_item) use ($item_id) {
return $line_item->item_id === $item_id;
});
}
1 change: 1 addition & 0 deletions VariableAnalysis/Lib/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ public static function getFunctionIndexForFunctionArgument(File $phpcsFile, $sta
$nonFunctionTokenTypes[] = T_COMMA;
$nonFunctionTokenTypes[] = T_STRING;
$nonFunctionTokenTypes[] = T_BITWISE_AND;
$nonFunctionTokenTypes[] = T_NS_SEPARATOR;
$functionPtr = self::getIntOrNull($phpcsFile->findPrevious($nonFunctionTokenTypes, $stackPtr - 1, null, true, null, true));
if (! is_int($functionPtr)) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -587,11 +587,11 @@ protected function processVariableAsUseImportDefinition(File $phpcsFile, $stackP

$endOfArgsPtr = $phpcsFile->findPrevious([T_CLOSE_PARENTHESIS], $stackPtr - 1, null);
if (! is_int($endOfArgsPtr)) {
throw new \Exception("Arguments index not found for function use index {$stackPtr}");
throw new \Exception("Arguments index not found for function use index {$stackPtr} when processing variable {$varName}");
}
$functionPtr = Helpers::getFunctionIndexForFunctionArgument($phpcsFile, $endOfArgsPtr);
if (! is_int($functionPtr)) {
throw new \Exception("Function index not found for function use index {$stackPtr}");
throw new \Exception("Function index not found for function use index {$stackPtr} when processing variable {$varName}");
}

// Use is both a read (in the enclosing scope) and a define (in the function scope)
Expand Down