Skip to content

Language: Attributes (#[...]) syntax + runtime metadata + ReflectionAttribute parity #4392

Description

@PurHur

Category

language (umbrella — split work across linked issues)

Status (2026-06-03 audit)

Partial landing. Attributes parse/compile on classes/methods/properties; VM reflection read paths exist for some targets. Remaining gaps are tracked as child issues — do not implement the full umbrella in one PR.

Gap Issue
Builtin Attribute class + class_exists('Attribute') #5142
#[\DelayedTargetValidation] (PHP 8.4) #5124
#[AllowDynamicProperties] on parameter → compile error #5137
ReflectionProperty property attrs/types #4384
Built-in #[\SensitiveParameter] on ReflectionParameter::getAttributes() #5152
ReflectionAttribute::newInstance() #3206 (closed — reopen if regressed)
JIT/AOT attribute metadata tables #2467 (closed — verify native binaries)

Problem

Frameworks need end-to-end attribute parity: parse, store metadata, reflect, and (PHP 8.4+) validate targets. This umbrella coordinates child issues toward Zend behavior.

php-src reference

Repro (integration — pick a failing child)

<?php
#[Attribute]
class DemoAttr {
    public function __construct(public string $x) {}
}

#[DemoAttr('ok')]
function f(#[DemoAttr('p')] int $a) {}

echo (int) class_exists('Attribute'), "\n";
$r = new ReflectionFunction('f');
echo count($r->getAttributes()), "\n";
$paramAttrs = $r->getParameters()[0]->getAttributes();
echo count($paramAttrs), "\n";
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php repro.php
php bin/vm.php repro.php
'
Check Zend vm.php (typical today)
class_exists('Attribute') 1 0 → #5142
function getAttributes() count 1 may work
parameter getAttributes() count 1 may work

Scope (umbrella — do not duplicate child PRs)

Done when (umbrella closes)

  • All child issues in the table above are closed or explicitly deferred with compliance coverage
  • Integration repro matches Zend on VM
  • php script/capability-syntax.php documents JIT/AOT attribute reflection state

North star

#1492 self-host — attribute metadata must survive in native binaries without Zend.

Worker guidance

Claim a child issue, not this umbrella, unless coordinating metadata schema shared by multiple targets.

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

    MOST IMPORTANTThis are the most important targetsarea:compilerCompiler / CFG / JITarea:vmVirtual machineimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-2:languagePhase 2 – language features

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions