phpstan-wordpress
phpstan-wordpress copied to clipboard
ReturnTypeExtension for wp_hash_password()
The return value of wp_hash_password() is determined by one of the following:
\PasswordHash::HashPassword()– always returns anon-falsy-string.password_hash()– returns anon-falsy-stringfor valid algorithms. For invalid algorithms, it gives a warning and returnsnullon PHP 7 and throws aValueErroron PHP 8.base64_encode(hash_hmac())– returns anon-falsy-stringfor valid algorithms. For invalid algorithms, it gives a warning and returns an empty string ('') on PHP 7 and throws aValueErroron PHP 8.'*'.
The applied algorithm is filterable and not validated. Consequently, the overall return type is string|null on PHP 7 and non-falsy-string on PHP 8.
Leaving this here for future reference, or in case somebody wishes to take it up.