Category
language
Problem
#1354 ✅ and #1936 ✅ delivered VM v1: attributes parse, compile-time metadata on TYPE_DECLARE_CLASS / TYPE_DECLARE_METHOD, and read-only reflection (ReflectionClass::getAttributes(), ReflectionAttribute::getName()).
docs/capabilities-syntax.md still marks attributes as JIT/AOT deferred. Native bin/jit.php / phpc build binaries used in self-host must expose the same metadata as VM or reflection returns empty arrays / stubs.
php-src reference
Zend/zend_compile.c — zend_compile_attributes, attachment to op_array / class_entry
Zend/zend_reflection.c — zim_ReflectionClass_getAttributes, ReflectionAttribute object creation
ext/reflection/php_reflection.c
Repro (today)
Save as test/compliance/cases/attribute_reflection_probe.php (or run inline):
<?php
#[\Attribute]
class Route {
public function __construct(public string $path) {}
}
#[Route('/home')]
class Home {}
$r = new ReflectionClass(Home::class);
$attrs = $r->getAttributes();
echo count($attrs), "\n";
echo $attrs[0]->getName(), "\n";
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php -r "/* paste */" # Zend: 1, Route
php bin/vm.php test/compliance/cases/attribute_reflection_probe.php 2>/dev/null || php bin/vm.php -r "..."
php bin/jit.php -r "/* same */" 2>&1 | head -5
'
Expected Zend: 1 and Route (or fully qualified name). Gap: compare VM vs JIT vs AOT output; file fails if JIT/AOT prints 0 or fatals.
Scope (this repo)
| Layer |
Files |
v1 target |
| Compiler |
lib/Compiler.php |
Serialize attribute class names + literal args into IR metadata |
| VM |
lib/VM.php, lib/VM/BuiltinClasses.php |
Already partial — extend if gaps found |
| JIT |
lib/JIT.php |
Emit const attribute tables into VMContext for reflection |
| AOT |
lib/AOT/ |
Link metadata section; bootstrap-readable |
| Tests |
test/compliance/cases/attribute_reflection_*.phpt |
VM + @group llvm JIT |
Out of scope (v1)
Done when
Verification
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit --filter attribute_reflection'
./script/ci-fast.sh --filter attribute_reflection
Dependencies
Links
Category
languageProblem
#1354 ✅ and #1936 ✅ delivered VM v1: attributes parse, compile-time metadata on
TYPE_DECLARE_CLASS/TYPE_DECLARE_METHOD, and read-only reflection (ReflectionClass::getAttributes(),ReflectionAttribute::getName()).docs/capabilities-syntax.mdstill marks attributes as JIT/AOT deferred. Nativebin/jit.php/phpc buildbinaries used in self-host must expose the same metadata as VM or reflection returns empty arrays / stubs.php-src reference
Zend/zend_compile.c—zend_compile_attributes, attachment to op_array / class_entryZend/zend_reflection.c—zim_ReflectionClass_getAttributes,ReflectionAttributeobject creationext/reflection/php_reflection.cRepro (today)
Save as
test/compliance/cases/attribute_reflection_probe.php(or run inline):Expected Zend:
1andRoute(or fully qualified name). Gap: compare VM vs JIT vs AOT output; file fails if JIT/AOT prints0or fatals.Scope (this repo)
lib/Compiler.phplib/VM.php,lib/VM/BuiltinClasses.phplib/JIT.phpVMContextfor reflectionlib/AOT/test/compliance/cases/attribute_reflection_*.phpt@group llvmJITOut of scope (v1)
ReflectionAttribute::newInstance()with arbitrary constructorsDone when
getAttributes()count +getName()match Zend for class-level attributephp script/capability-syntax.php— attributes row JIT/AOT = yes (read path)php script/bootstrap-inventory.php --checkclean or documented deltaVerification
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit --filter attribute_reflection' ./script/ci-fast.sh --filter attribute_reflectionDependencies
Links
docs/capabilities-syntax.mdPHP 8 attributes row