From 4c0cae7cd032bd3ac59446447e6400567ece38e1 Mon Sep 17 00:00:00 2001 From: kkmuffme <11071985+kkmuffme@users.noreply.github.com> Date: Thu, 29 Dec 2022 23:14:56 +0100 Subject: [PATCH] code style --- .../Internal/Analyzer/FunctionLike/ReturnTypeAnalyzer.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Psalm/Internal/Analyzer/FunctionLike/ReturnTypeAnalyzer.php b/src/Psalm/Internal/Analyzer/FunctionLike/ReturnTypeAnalyzer.php index dbffad76d..25e68730d 100644 --- a/src/Psalm/Internal/Analyzer/FunctionLike/ReturnTypeAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/FunctionLike/ReturnTypeAnalyzer.php @@ -241,9 +241,8 @@ class ReturnTypeAnalyzer } $inferred_return_type_parts_with_never = $inferred_return_type_parts; - $number_of_types = count($inferred_return_type_parts); // we filter TNever that have no bearing on the return type - if ($number_of_types > 1) { + if (count($inferred_return_type_parts) > 1) { $inferred_return_type_parts = array_filter( $inferred_return_type_parts, static fn(Union $union_type): bool => !$union_type->isNever() @@ -260,7 +259,7 @@ class ReturnTypeAnalyzer } // void + never = null, so we need to check this separately - if ($number_of_types > 1 + if (count($inferred_return_type_parts_with_never) > 1 && !$function_always_exits && $inferred_return_type_parts_with_never !== $inferred_return_type_parts) { $inferred_return_type_with_never = Type::combineUnionTypeArray( @@ -614,8 +613,7 @@ class ReturnTypeAnalyzer return false; } } - } elseif ( - ($declared_return_type->explicit_never === false || !$declared_return_type->isNull()) + } elseif (($declared_return_type->explicit_never === false || !$declared_return_type->isNull()) && ( !$declared_return_type->isNullable() || ($parent_class === null && $self_fq_class_name === $source->getFQCLN())