Category
stdlib + compile lowering · php-src-strict
Problem
password_hash($password, PASSWORD_BCRYPT) works, and password_hash($password, 1, ['cost' => 4]) works, but password_hash($password, PASSWORD_BCRYPT, ['cost' => 4]) passes null as argument #2 ($algo) → TypeError. Zend accepts the call and returns a bcrypt hash string.
Related but distinct from #9275 (PASSWORD_DEFAULT resolves null in other contexts).
Repro
./script/docker-exec.sh -- bash -lc 'php bin/vm.php test/repro/maintainer_gap_password_hash_options.php 2>&1'
# no-opt ok
# with-opt TypeError: Argument #2 ($algo) must be of type string|int, null given
# lit-opt ok
test/repro/maintainer_gap_password_hash_options.php:
password_hash('test', PASSWORD_BCRYPT); // ok
password_hash('test', PASSWORD_BCRYPT, ['cost' => 4]); // TypeError — must hash
password_hash('test', 1, ['cost' => 4]); // ok
php-src reference
ext/standard/password.c — PHP_FUNCTION(password_hash)
Implementation (PHP-in-PHP)
Done when
Category
stdlib+ compile lowering · php-src-strictProblem
password_hash($password, PASSWORD_BCRYPT)works, andpassword_hash($password, 1, ['cost' => 4])works, butpassword_hash($password, PASSWORD_BCRYPT, ['cost' => 4])passesnullas argument #2 ($algo) →TypeError. Zend accepts the call and returns a bcrypt hash string.Related but distinct from #9275 (PASSWORD_DEFAULT resolves null in other contexts).
Repro
test/repro/maintainer_gap_password_hash_options.php:php-src reference
ext/standard/password.c—PHP_FUNCTION(password_hash)Implementation (PHP-in-PHP)
lib/Compiler.php/ VM call path, not new Cext/standard/password_hash.phpreceives the resolved algo int/stringDone when
password_hash()paths (Stdlib: PASSWORD_DEFAULT constant resolves NULL — password_hash() TypeError (ext/standard/password.c) #9275)