diff --git a/src/Psalm/Checker/FunctionLikeChecker.php b/src/Psalm/Checker/FunctionLikeChecker.php index 35074a861..93f880edc 100644 --- a/src/Psalm/Checker/FunctionLikeChecker.php +++ b/src/Psalm/Checker/FunctionLikeChecker.php @@ -821,7 +821,7 @@ abstract class FunctionLikeChecker extends SourceChecker implements StatementsSo return ($namespace ? strtolower($namespace) . '\\' : '') . strtolower($this->function->name); } - return $this->getFilePath() . ':' . $this->function->getLine() . '::-closure'; + return $this->getFilePath() . ':' . $this->function->getLine() . ':-:closure'; } /** diff --git a/src/Psalm/Checker/Statements/ExpressionChecker.php b/src/Psalm/Checker/Statements/ExpressionChecker.php index c60eebe5e..c9b982982 100644 --- a/src/Psalm/Checker/Statements/ExpressionChecker.php +++ b/src/Psalm/Checker/Statements/ExpressionChecker.php @@ -1820,19 +1820,17 @@ class ExpressionChecker if (strtolower($return_type->value) === 'static' || !$method_id) { $return_type->value = $calling_class; + } elseif (strpos($method_id, ':-:closure') !== false) { + $return_type->value = $calling_class; } else { list(, $method_name) = explode('::', $method_id); - if ($method_name === '-closure') { - $return_type->value = $calling_class; - } else { - $appearing_method_id = MethodChecker::getAppearingMethodId( - $project_checker, - $calling_class . '::' . $method_name - ); + $appearing_method_id = MethodChecker::getAppearingMethodId( + $project_checker, + $calling_class . '::' . $method_name + ); - $return_type->value = explode('::', (string)$appearing_method_id)[0]; - } + $return_type->value = explode('::', (string)$appearing_method_id)[0]; } } } diff --git a/src/Psalm/Visitor/DependencyFinderVisitor.php b/src/Psalm/Visitor/DependencyFinderVisitor.php index c74938450..211291007 100644 --- a/src/Psalm/Visitor/DependencyFinderVisitor.php +++ b/src/Psalm/Visitor/DependencyFinderVisitor.php @@ -599,7 +599,7 @@ class DependencyFinderVisitor extends PhpParser\NodeVisitorAbstract implements P $storage->visibility = ClassLikeChecker::VISIBILITY_PUBLIC; } } else { - $function_id = $cased_function_id = $this->file_path . ':' . $stmt->getLine() . '::-closure'; + $function_id = $cased_function_id = $this->file_path . ':' . $stmt->getLine() . ':-:closure'; $storage = $this->file_storage->functions[$function_id] = new FunctionLikeStorage(); } diff --git a/tests/FunctionCallTest.php b/tests/FunctionCallTest.php index ccd264cc0..8fd466cf4 100644 --- a/tests/FunctionCallTest.php +++ b/tests/FunctionCallTest.php @@ -229,6 +229,17 @@ class FunctionCallTest extends TestCase ], 'error_levels' => ['MixedAssignment', 'MixedArgument'], ], + 'uasort' => [ + ' [], + 'error_levels' => ['MixedArrayAccess', 'MixedArgument', 'UntypedParam', 'MissingClosureReturnType'], + ], 'byRefAfterCallable' => [ '