Skip to content

Correct signatures for hash_hmac and hash_hmac_file#1852

Closed
madwizard-thomas wants to merge 1 commit intophpstan:masterfrom
madwizard-thomas:fix-hash-hmac
Closed

Correct signatures for hash_hmac and hash_hmac_file#1852
madwizard-thomas wants to merge 1 commit intophpstan:masterfrom
madwizard-thomas:fix-hash-hmac

Conversation

@madwizard-thomas
Copy link

Correction for hash_hmac and hash_hmac_file.
From PHP's documentation:
hash_hmac:

Returns FALSE when algo is unknown or is a non-cryptographic hash function.

hash_hmac_file:

Returns a string containing the calculated message digest as lowercase hexits unless raw_output is set to true in which case the raw binary representation of the message digest is returned. Returns FALSE when algo is unknown or is a non-cryptographic hash function, or if the file filename cannot be read.

@ondrejmirtes
Copy link
Member

Hi, this would be a better fit for a dynamic return type extension - if someone enters a valid algo in the first parameter, they don't want to be bothered with a false...

@ondrejmirtes
Copy link
Member

You can get inspired by a similar problem here: https://github.com/phpstan/phpstan/blob/master/src/Type/Php/MbFunctionsReturnTypeExtension.php

@ondrejmirtes
Copy link
Member

Closing after no response - feel free to submit a new PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants