Category
bug · php-src-strict · Reflection / openssl
Problem
openssl_pkey_derive is callable positionally and matches Zend ECDH output length, but Reflection advertises arity 0 / no return type, so named arguments are rejected.
| Repro |
Zend 8.2.32 |
VM (2026-08-05 @ b0b02b0ba) |
ReflectionFunction arity / return |
3 / string|false ($public_key, $private_key, ?int $key_length) |
0 / none |
openssl_pkey_derive($pub, $priv) (EC P-256) |
ok:32 |
ok:32 |
openssl_pkey_derive(public_key: $pub, private_key: $priv) |
ok:32 |
Error: Unknown named parameter $public_key |
php-src reference
PHP implementation target
ext/openssl/ stubs + Reflection metadata for param names/string|false return
- Keep positional ECDH path; enable named args via real arity — no new
runtime/*.c logic
Repro
./script/docker-exec.sh -- bash -lc 'cat > /tmp/derive_refl.php <<'"'"'PHP'"'"'
<?php
$r = new ReflectionFunction("openssl_pkey_derive");
echo "arity=", $r->getNumberOfParameters(), " ret=", $r->hasReturnType() ? (string)$r->getReturnType() : "none", "\n";
foreach ($r->getParameters() as $p) {
echo "p=$", $p->getName(), "\n";
}
$a = openssl_pkey_new(["curve_name" => "prime256v1", "private_key_type" => OPENSSL_KEYTYPE_EC]);
$b = openssl_pkey_new(["curve_name" => "prime256v1", "private_key_type" => OPENSSL_KEYTYPE_EC]);
$pub = openssl_pkey_get_public(openssl_pkey_get_details($b)["key"]);
$s = openssl_pkey_derive($pub, $a);
echo "pos=", is_string($s) ? ("ok:".strlen($s)) : var_export($s, true), "\n";
try {
$s2 = openssl_pkey_derive(public_key: $pub, private_key: $a);
echo "named=", is_string($s2) ? ("ok:".strlen($s2)) : var_export($s2, true), "\n";
} catch (Throwable $e) {
echo "named=", get_class($e), ":", $e->getMessage(), "\n";
}
PHP
php bin/vm.php /tmp/derive_refl.php
php /tmp/derive_refl.php'
Done when
Category
bug· php-src-strict · Reflection / opensslProblem
openssl_pkey_deriveis callable positionally and matches Zend ECDH output length, but Reflection advertises arity 0 / no return type, so named arguments are rejected.b0b02b0ba)ReflectionFunctionarity / return3/string|false($public_key,$private_key,?int $key_length)0/ noneopenssl_pkey_derive($pub, $priv)(EC P-256)ok:32ok:32openssl_pkey_derive(public_key: $pub, private_key: $priv)ok:32Error: Unknown named parameter $public_keyphp-src reference
ext/openssl/openssl.stub.php—openssl_pkey_deriveext/openssl/openssl.c—PHP_FUNCTION(openssl_pkey_derive)PHP implementation target
ext/openssl/stubs + Reflection metadata for param names/string|falsereturnruntime/*.clogicRepro
Done when
string|false, optionalkey_length)public_key/private_key/key_lengthaccepted and match positional ECDH