mirror of
https://github.com/danog/psalm.git
synced 2025-01-21 21:31:13 +01:00
Fix closure naming convention so it doesn’t confuse method id checks
This commit is contained in:
parent
83c65d4b2d
commit
a8a1489a8f
@ -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';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -229,6 +229,17 @@ class FunctionCallTest extends TestCase
|
||||
],
|
||||
'error_levels' => ['MixedAssignment', 'MixedArgument'],
|
||||
],
|
||||
'uasort' => [
|
||||
'<?php
|
||||
uasort(
|
||||
$manifest,
|
||||
function ($a, $b) {
|
||||
return strcmp($a["parent"],$b["parent"]);
|
||||
}
|
||||
);',
|
||||
'assertions' => [],
|
||||
'error_levels' => ['MixedArrayAccess', 'MixedArgument', 'UntypedParam', 'MissingClosureReturnType'],
|
||||
],
|
||||
'byRefAfterCallable' => [
|
||||
'<?php
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user