Skip to content

Commit 90b5b9f

Browse files
authored
Merge pull request #11421 from danog/fix_11420
Fix #11420
2 parents 309c8d4 + b869683 commit 90b5b9f

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

psalm.xml.dist

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
name="Psalm for Psalm"
66
errorLevel="1"
77
noCache="true"
8-
forceJit="true"
98
throwExceptionOnError="0"
109
findUnusedCode="true"
1110
ensureArrayStringOffsetsExist="true"

src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/AtomicMethodCallAnalyzer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -922,7 +922,7 @@ private static function handleCallableObject(
922922
$result->existent_method_ids[$method_id] = true;
923923
$result->has_valid_method_call_type = true;
924924

925-
if ($lhs_type_part_callable !== null) {
925+
if ($lhs_type_part_callable !== null && !$stmt->isFirstClassCallable()) {
926926
$result->return_type = $lhs_type_part_callable->return_type ?? Type::getMixed();
927927
$callableArgumentCount = count($lhs_type_part_callable->params ?? []);
928928
$providedArgumentsCount = count($stmt->getArgs());

tests/CallableTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -967,6 +967,27 @@ function appHandler3(int $param1, int $param2): array
967967
'ignored_issues' => [],
968968
'php_version' => '8.1',
969969
],
970+
'firstClassCallableFromObject' => [
971+
'code' => '<?php
972+
973+
function onKernelController(callable $controller): void
974+
{
975+
if (\is_array($controller)) {
976+
$controller = $controller[0];
977+
} else {
978+
try {
979+
$reflection = new \ReflectionFunction($controller(...));
980+
$controller = $reflection->getClosureThis();
981+
} catch (\ReflectionException) {
982+
return;
983+
}
984+
}
985+
}
986+
',
987+
'assertions' => [],
988+
'ignored_issues' => [],
989+
'php_version' => '8.1',
990+
],
970991
'inferTypeWhenClosureParamIsOmitted' => [
971992
'code' => '<?php
972993
/**

0 commit comments

Comments
 (0)