From 034525463563026a1ed6da3e42ad697065b547dc Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Mon, 21 Nov 2022 20:52:58 +0100 Subject: [PATCH] Reuse code --- .../Statements/Expression/AssertionFinder.php | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/AssertionFinder.php b/src/Psalm/Internal/Analyzer/Statements/Expression/AssertionFinder.php index 7d313b351..8d6e43188 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/AssertionFinder.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/AssertionFinder.php @@ -3684,16 +3684,9 @@ class AssertionFinder || $atomic_type instanceof TKeyedArray ) { if ($atomic_type instanceof TKeyedArray) { - $key_possibly_undefined = false; - - foreach ($atomic_type->properties as $property_type) { - if ($property_type->possibly_undefined) { - $key_possibly_undefined = true; - break; - } - } - - $key_type = $atomic_type->getGenericKeyType($key_possibly_undefined); + $key_type = $atomic_type->getGenericKeyType( + !$atomic_type->allShapeKeysAlwaysDefined() + ); } else { $key_type = $atomic_type->type_params[0]; }