Category
stdlib · php-src-strict
Problem
ReflectionParameter parity gaps vs Zend: parameter attributes, type information (nullable / union / intersection / DNF), and default value introspection must match php-src. PHPUnit, DI containers, and this compiler's own reflection tests depend on ReflectionParameter::getAttributes(), getType(), isDefaultValueAvailable(), and getDefaultValue().
Current VM reflection returns incomplete metadata for parameters (attributes on params were deferred from the initial attribute rollout).
php-src reference
Repro (failure today)
<?php
declare(strict_types=1);
#[Attribute]
final class A {
public function __construct(public string $x) {}
}
class C {
public function f(#[A('p')] ?int $p = 42, string ...$rest) {}
}
$rm = new ReflectionMethod(C::class, 'f');
$rp = $rm->getParameters()[0];
echo $rp->getName(), "\n";
echo ($rp->hasType() ? $rp->getType()->__toString() : 'no-type'), "\n";
echo ($rp->isDefaultValueAvailable() ? 'has-default' : 'no-default'), "\n";
if ($rp->isDefaultValueAvailable()) {
var_export($rp->getDefaultValue());
echo "\n";
}
$attrs = $rp->getAttributes(A::class);
echo count($attrs), "\n";
if ($attrs) {
$inst = $attrs[0]->newInstance();
echo $inst->x, "\n";
}
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php repro.php
php bin/vm.php repro.php
'
| Check |
Zend |
VM today |
getName() |
p |
may work |
getType() |
?int |
incomplete |
getDefaultValue() |
42 |
missing/wrong |
getAttributes(A::class) |
count 1, x=p |
count 0 ❌ |
Scope (PHP-in-PHP)
| Path |
Work |
ext/standard/VmReflection.php |
ReflectionParameter methods |
lib/VM/BuiltinClasses.php |
arg metadata from compile table |
lib/VM/ReflectionSupport.php |
attribute materialization for ZEND_ATTRIBUTE_TARGET_PARAMETER |
script/capability-matrix.php |
reflection rows |
Done when (php-src-strict)
Related
Category
stdlib· php-src-strictProblem
ReflectionParameterparity gaps vs Zend: parameter attributes, type information (nullable / union / intersection / DNF), and default value introspection must match php-src. PHPUnit, DI containers, and this compiler's own reflection tests depend onReflectionParameter::getAttributes(),getType(),isDefaultValueAvailable(), andgetDefaultValue().Current VM reflection returns incomplete metadata for parameters (attributes on params were deferred from the initial attribute rollout).
php-src reference
ext/reflection/php_reflection.c—reflection_parameter_*handlersZend/zend_attributes.c—ZEND_ATTRIBUTE_TARGET_PARAMETERZend/zend_compile.c— arg info, default values,zend_compile_arg_infoZend/zend_ast.c— default constant expression serializationRepro (failure today)
getName()pgetType()?intgetDefaultValue()42getAttributes(A::class)1,x=p0❌Scope (PHP-in-PHP)
ext/standard/VmReflection.phpReflectionParametermethodslib/VM/BuiltinClasses.phplib/VM/ReflectionSupport.phpZEND_ATTRIBUTE_TARGET_PARAMETERscript/capability-matrix.phpDone when (php-src-strict)
...$restparameter:isVariadic()true; no false defaulttest/compliance/cases/stdlib/reflection_parameter_attributes.phptgreen./script/ci-fast.sh --filter reflection_parametergreenRelated