diff --git a/src/Psalm/Internal/Analyzer/FunctionLike/ReturnTypeAnalyzer.php b/src/Psalm/Internal/Analyzer/FunctionLike/ReturnTypeAnalyzer.php index 95a20caff..c9fa757de 100644 --- a/src/Psalm/Internal/Analyzer/FunctionLike/ReturnTypeAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/FunctionLike/ReturnTypeAnalyzer.php @@ -361,6 +361,8 @@ class ReturnTypeAnalyzer $parent_class = null; + $classlike_storage = null; + if ($self_fq_class_name) { $classlike_storage = $codebase->classlike_storage_provider->get($self_fq_class_name); $parent_class = $classlike_storage->parent_class; @@ -376,6 +378,7 @@ class ReturnTypeAnalyzer true, true, $function_like_storage instanceof MethodStorage && $function_like_storage->final + || ($classlike_storage && $classlike_storage->final) ); if (!$inferred_return_type_parts diff --git a/tests/TraitTest.php b/tests/TraitTest.php index d305ebace..84ed48b77 100644 --- a/tests/TraitTest.php +++ b/tests/TraitTest.php @@ -973,6 +973,19 @@ class TraitTest extends TestCase use Foo; }' ], + 'staticReturnWithFinal' => [ + '