From 7ac6d2e5a47968c07e2e55a9ceae17e66959dc6a Mon Sep 17 00:00:00 2001 From: Bauke van der Woude Date: Tue, 18 Aug 2020 15:35:31 +0200 Subject: [PATCH] Fix hash_*() signatures (#4014) Functions can return false when an invalid algorithm is supplied --- src/Psalm/Internal/CallMap.php | 10 +++++----- tests/FunctionCallTest.php | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Psalm/Internal/CallMap.php b/src/Psalm/Internal/CallMap.php index 72cce19aabb..b0dde30b5da 100644 --- a/src/Psalm/Internal/CallMap.php +++ b/src/Psalm/Internal/CallMap.php @@ -4251,18 +4251,18 @@ 'HaruPage::stroke' => ['bool', 'close_path='=>'bool'], 'HaruPage::textOut' => ['bool', 'x'=>'float', 'y'=>'float', 'text'=>'string'], 'HaruPage::textRect' => ['bool', 'left'=>'float', 'top'=>'float', 'right'=>'float', 'bottom'=>'float', 'text'=>'string', 'align='=>'int'], -'hash' => ['string', 'algo'=>'string', 'data'=>'string', 'raw_output='=>'bool'], +'hash' => ['string|false', 'algo'=>'string', 'data'=>'string', 'raw_output='=>'bool'], 'hash_algos' => ['list'], 'hash_copy' => ['HashContext', 'context'=>'HashContext|resource'], 'hash_equals' => ['bool', 'known_string'=>'string', 'user_string'=>'string'], 'hash_file' => ['string|false', 'algo'=>'string', 'filename'=>'string', 'raw_output='=>'bool'], 'hash_final' => ['string', 'context'=>'HashContext|resource', 'raw_output='=>'bool'], 'hash_hkdf' => ['string|false', 'algo'=>'string', 'ikm'=>'string', 'length='=>'int', 'info='=>'string', 'salt='=>'string'], -'hash_hmac' => ['string', 'algo'=>'string', 'data'=>'string', 'key'=>'string', 'raw_output='=>'bool'], +'hash_hmac' => ['string|false', 'algo'=>'string', 'data'=>'string', 'key'=>'string', 'raw_output='=>'bool'], 'hash_hmac_algos' => ['list'], -'hash_hmac_file' => ['string', 'algo'=>'string', 'filename'=>'string', 'key'=>'string', 'raw_output='=>'bool'], -'hash_init' => ['HashContext', 'algo'=>'string', 'options='=>'int', 'key='=>'string'], -'hash_pbkdf2' => ['string', 'algo'=>'string', 'password'=>'string', 'salt'=>'string', 'iterations'=>'int', 'length='=>'int', 'raw_output='=>'bool'], +'hash_hmac_file' => ['string|false', 'algo'=>'string', 'filename'=>'string', 'key'=>'string', 'raw_output='=>'bool'], +'hash_init' => ['HashContext|false', 'algo'=>'string', 'options='=>'int', 'key='=>'string'], +'hash_pbkdf2' => ['string|false', 'algo'=>'string', 'password'=>'string', 'salt'=>'string', 'iterations'=>'int', 'length='=>'int', 'raw_output='=>'bool'], 'hash_update' => ['bool', 'context'=>'HashContext', 'data'=>'string'], 'hash_update_file' => ['bool', 'context'=>'HashContext', 'filename'=>'string', 'scontext='=>'?HashContext'], 'hash_update_stream' => ['int', 'context'=>'HashContext', 'handle'=>'resource', 'length='=>'int'], diff --git a/tests/FunctionCallTest.php b/tests/FunctionCallTest.php index 632f00139cd..2f50e77d73c 100644 --- a/tests/FunctionCallTest.php +++ b/tests/FunctionCallTest.php @@ -873,7 +873,7 @@ class Foo {} ' 'HashContext', + '$h' => 'HashContext|false', ], [], '7.2', @@ -882,7 +882,7 @@ class Foo {} ' 'HashContext', + '$h' => 'HashContext|false', ], [], '7.3',