[php-src] Issue #7759: Incorrect return types for hash() and hash_hmac()

From: Date: Sat, 11 Dec 2021 16:18:16 +0000
Subject: [php-src] Issue #7759: Incorrect return types for hash() and hash_hmac()
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-238337@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/7759 Author: jlherren ### Description I believe the stub file entries for [hash()](https://github.com/php/php-src/blob/701e5fe4aecfa4ba75d71c4ebe37e0e0cc8ed131/ext/hash/hash.stub.php#L6) and [hash_hmac()](https://github.com/php/php-src/blob/701e5fe4aecfa4ba75d71c4ebe37e0e0cc8ed131/ext/hash/hash.stub.php#L12) to be incorrect. Their return types are both specified as string|false, but starting with PHP 8.0 they in fact never return false, they throw a fatal error where they returned false before PHP 8.0. In the case of hash() the only two RETURN_FALSE statements ([1](https://github.com/php/php-src/blob/701e5fe4aecfa4ba75d71c4ebe37e0e0cc8ed131/ext/hash/hash.c#L519), [2](https://github.com/php/php-src/blob/701e5fe4aecfa4ba75d71c4ebe37e0e0cc8ed131/ext/hash/hash.c#L543)) are within if (isfilename)blocks, e.g. the code path used exclusively by hash_file(). It's similar for hash_hmac(). Does that make sense or did I miss something? ### PHP Version PHP >= 8.0 ### Operating System All OSes

« previous php.bugs (#238337) next »