Skip to content

Stdlib: password_needs_rehash() missing args throws LogicException not ArgumentCountError (ext/standard/password.c) #9263

Description

@PurHur

Category

stdlib · php-src-strict

Problem

Calling password_needs_rehash() with fewer than two arguments must throw ArgumentCountError with php-src message text. VM throws LogicException instead, breaking catch (ArgumentCountError) branches and error-handler parity.

Valid 2/3-arg calls are unaffected; this is exception class + message only.

php-src reference

Repro (failure today — verified 2026-06-19)

<?php
$hash = password_hash('x', PASSWORD_BCRYPT);
try {
    password_needs_rehash($hash);
} catch (Throwable $e) {
    echo get_class($e), ': ', $e->getMessage(), "\n";
}
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php repro.php
php bin/vm.php repro.php
'
Engine Exception Message
Zend PHP 8.2 ArgumentCountError password_needs_rehash() expects at least 2 arguments, 1 given
VM today LogicException password_needs_rehash() requires two or three arguments

Zero-arg probe

php bin/vm.php -r 'try { password_needs_rehash(); } catch (Throwable $e) { echo get_class($e); }'
# VM: LogicException — Zend: ArgumentCountError

Scope (PHP-in-PHP)

Path Work
ext/standard/password_needs_rehash.php replace LogicException arity throws with ArgumentCountError matching php-src text
lib/VM/InternalStrictArg.php or shared arity helper reuse across password_* family if duplicated
ext/standard/JitPassword.php (if present) same exception class in JIT lowering

No new C runtime.

Done when

  • Too-few-args (0 or 1 arg) → ArgumentCountError with php-src message on VM
  • JIT/AOT match when password builtins are JIT-compiled
  • Valid password_needs_rehash($hash, PASSWORD_BCRYPT) unchanged
  • Compliance: test/compliance/cases/stdlib/password_needs_rehash_arity.phpt
  • ./script/ci-fast.sh --filter password_needs_rehash_arity green

Related

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:vmVirtual machineenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-4:stdlibPhase 4 – stdlib for web appsstdlib

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions