Category
stdlib · php-src-strict · PHP 8.4 · ext/hash phase 2
Problem
PHP 8.4 added HashContext::__debugInfo() so var_dump(hash_init('sha256')) prints a safe summary instead of leaking internal hash state. This compiler has no HashContext class at all today (class_exists('HashContext') === false; incremental hashing tracked in #3357 / #6937).
Even after hash_init() lands, parity requires the debug hook.
php-src reference
Repro (failure today)
<?php
declare(strict_types=1);
var_dump(class_exists('HashContext', false));
if (!function_exists('hash_init')) {
echo "hash_init: no\n";
exit(0);
}
$ctx = hash_init('sha256');
var_dump($ctx->__debugInfo());
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/vm.php -r "var_dump(class_exists(\"HashContext\", false));"'
| Check |
Zend PHP 8.4 |
bin/vm.php |
class_exists('HashContext') |
true |
false |
->__debugInfo() keys |
['algo' => 'sha256'] (no secret state) |
not reached |
Scope (PHP-in-PHP first)
| Layer |
Path |
| Prerequisite |
#3357 / #6937 — hash_init() returns HashContext object |
| VM class |
register HashContext in lib/VM/BuiltinClasses.php |
| Method |
__debugInfo(): array in PHP (ext/hash/HashContext.php or ext/standard/VmHash.php) — expose algorithm name only |
| Tests |
test/compliance/cases/stdlib/hash_context_debug_info.phpt |
Done when
Verification
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
vendor/bin/phpunit --filter hash_context_debug_info'
Related
Category
stdlib· php-src-strict · PHP 8.4 · ext/hash phase 2Problem
PHP 8.4 added
HashContext::__debugInfo()sovar_dump(hash_init('sha256'))prints a safe summary instead of leaking internal hash state. This compiler has noHashContextclass at all today (class_exists('HashContext') === false; incremental hashing tracked in #3357 / #6937).Even after
hash_init()lands, parity requires the debug hook.php-src reference
ext/hash/hash.c—hash_context_object_handlers.debug_info/zim_HashContext___debugInfoext/hash/hash.stub.phpRepro (failure today)
bin/vm.phpclass_exists('HashContext')truefalse->__debugInfo()keys['algo' => 'sha256'](no secret state)Scope (PHP-in-PHP first)
hash_init()returnsHashContextobjectHashContextinlib/VM/BuiltinClasses.php__debugInfo(): arrayin PHP (ext/hash/HashContext.phporext/standard/VmHash.php) — expose algorithm name onlytest/compliance/cases/stdlib/hash_context_debug_info.phptDone when
HashContextexists afterhash_init()var_dump($ctx)/$ctx->__debugInfo()matches Zend output shape (no raw digest state)./script/ci-fast.sh --filter hash_context_debug_infogreenVerification
Related