Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect return types for hash() and hash_hmac() #7759

Closed
jlherren opened this issue Dec 11, 2021 · 1 comment
Closed

Incorrect return types for hash() and hash_hmac() #7759

jlherren opened this issue Dec 11, 2021 · 1 comment

Comments

@jlherren
Copy link

Description

I believe the stub file entries for hash() and hash_hmac() 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, 2) 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

@cmb69
Copy link
Member

cmb69 commented Dec 11, 2021

Good catch! Thank you!

@cmb69 cmb69 self-assigned this Dec 11, 2021
cmb69 added a commit to cmb69/php-src that referenced this issue Dec 11, 2021
`hash()` and `hash_hmac()` never return `false`; only `hash_file()` and
`hash_hmac_file()` return `false` in case the data cannot be read.
@cmb69 cmb69 closed this as completed in 0b3a937 Dec 12, 2021
cmb69 added a commit that referenced this issue Dec 12, 2021
* PHP-8.0:
  Fix GH-7759: Incorrect return types for hash() and hash_hmac()
cmb69 added a commit that referenced this issue Dec 12, 2021
* PHP-8.1:
  Fix GH-7759: Incorrect return types for hash() and hash_hmac()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants
@jlherren @cmb69 and others