From afc3a76bc0177fa8cafbd87349f527aaa90a72c7 Mon Sep 17 00:00:00 2001 From: orklah Date: Sat, 8 Jan 2022 22:18:17 +0100 Subject: [PATCH] Seal the array inferred for hrtime --- .../Call/FunctionCallReturnTypeFetcher.php | 28 +++++++++---------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/FunctionCallReturnTypeFetcher.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/FunctionCallReturnTypeFetcher.php index 7a61039cdc1..41dbfc51006 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/FunctionCallReturnTypeFetcher.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/FunctionCallReturnTypeFetcher.php @@ -326,12 +326,12 @@ private static function getReturnTypeFromCallMapWithArgs( if (!$call_args) { switch ($call_map_key) { case 'hrtime': - return new Union([ - new TKeyedArray([ - Type::getInt(), - Type::getInt() - ]) + $keyed_array = new TKeyedArray([ + Type::getInt(), + Type::getInt() ]); + $keyed_array->sealed = true; + return new Union([$keyed_array]); case 'get_called_class': return new Union([ @@ -441,20 +441,18 @@ private static function getReturnTypeFromCallMapWithArgs( return $int; } + $keyed_array = new TKeyedArray([ + Type::getInt(), + Type::getInt() + ]); + $keyed_array->sealed = true; + if ((string) $first_arg_type === 'false') { - return new Union([ - new TKeyedArray([ - Type::getInt(), - Type::getInt() - ]) - ]); + return new Union([$keyed_array]); } return new Union([ - new TKeyedArray([ - Type::getInt(), - Type::getInt() - ]), + $keyed_array, new TInt() ]); }