diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/CallAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/CallAnalyzer.php index a39312d14..2d17a1faa 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/CallAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/CallAnalyzer.php @@ -1386,8 +1386,8 @@ class CallAnalyzer $fleshed_out_type = ExpressionAnalyzer::fleshOutType( $codebase, $param_type, - $fq_class_name, - $fq_class_name + $fq_class_name ?: $context->self, + $fq_class_name ?: $context->self ); if ($arg->unpack) { diff --git a/src/Psalm/Internal/Analyzer/Statements/ExpressionAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/ExpressionAnalyzer.php index 54729eeba..dd4d51ab6 100644 --- a/src/Psalm/Internal/Analyzer/Statements/ExpressionAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/ExpressionAnalyzer.php @@ -976,6 +976,15 @@ class ExpressionAnalyzer ); } + $return_type->value = $self_class; + } elseif ($return_type_lc === 'parent') { + if (!$self_class) { + throw new \UnexpectedValueException( + 'Cannot handle ' . $return_type->value . ' when $self_class is empty' + ); + } + var_dump('here'); + $return_type->value = $self_class; } else { $return_type->value = $codebase->classlikes->getUnAliasedName($return_type->value); diff --git a/tests/CallableTest.php b/tests/CallableTest.php index 2a25500cc..f0e066925 100644 --- a/tests/CallableTest.php +++ b/tests/CallableTest.php @@ -677,6 +677,31 @@ class CallableTest extends TestCase /** @psalm-suppress UndefinedClass */ array_map(["two", "three"], ["one", "two"]);', ], + 'callableSelfArg' => [ + '