php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #81299 password_hash() documentation is missing PHP 8 changes
Submitted: 2021-07-26 09:48 UTC Modified: 2021-07-26 11:20 UTC
From: enumag at gmail dot com Assigned: cmb (profile)
Status: Closed Package: Documentation problem
PHP Version: 8.0.8 OS: any
Private report: No CVE-ID: None
 [2021-07-26 09:48 UTC] enumag at gmail dot com
Description:
------------
In PHP 8 password_hash seems to be change to always return string or throw an error. Meaning it can no longer return false on null.

See https://3v4l.org/dtcXu

This change however is not documented: https://www.php.net/manual/en/function.password-hash.php


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-07-26 09:57 UTC] enumag at gmail dot com
Also it seems that return value is not correctly documented for older PHP versions either. Documentation claims it returns string or false but if you pass an invalid algorithm it actually returns NULL on PHP 7.3 and 7.4.

https://3v4l.org/vugc3
 [2021-07-26 11:20 UTC] cmb@php.net
-Status: Open +Status: Verified -Assigned To: +Assigned To: cmb
 [2021-07-26 11:20 UTC] cmb@php.net
> Documentation claims it returns string or false but if you pass
> an invalid algorithm it actually returns NULL on PHP 7.3 and 7.4.

From the docs[1]:

| If the parameters given to a function are not what it expects,
| such as passing an array where a string is expected, the return
| value of the function is undefined. In this case it will likely
| return null but this is just a convention, and cannot be relied
| upon.

[1] <https://www.php.net/manual/en/functions.internal.php>
 [2021-07-26 11:21 UTC] git@php.net
Automatic comment on behalf of cmb69
Revision: https://github.com/php/doc-en/commit/79c06cc0e7872f1401a4c37dc9298b0bedb0dde4
Log: Fix #81299: password_hash() documentation is missing PHP 8 changes
 [2021-07-26 11:21 UTC] git@php.net
-Status: Verified +Status: Closed
 [2021-07-26 13:12 UTC] git@php.net
Automatic comment on behalf of mumumu
Revision: https://github.com/php/doc-ja/commit/09d8f2872ea62bc2226c4ba7b4d453eb056c1e66
Log: Fix #81299: password_hash() documentation is missing PHP 8 changes
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 14:01:28 2024 UTC