Skip to content

Language: PHP 8 attributes — compliance PHPT pack (#1354 VM v1) #1912

Description

@PurHur

Problem

#1354 tracks PHP 8 #[...] attributes on classes, methods, properties, and parameters. Wave 3 is 12/13 with only attributes open (#1380, #1751). There is no compliance PHPT proving decorated declarations parse and execute (attributes ignored at runtime per PHP semantics).

Contributors cannot land #1354 incrementally without a green VM slice in ci-fast.sh (#1904 waits on this).

Scope (v1 — VM only)

  1. Parse attribute groups on class, method, property, parameter, constant declarations (host php-parser on PHP 8.2+ — Dependencies: php-parser token map for PHP 8.2+ host runs #113)
  2. Store metadata on compiler class table (or strip before lowering — document choice)
  3. Runtime: ignore attributes for execution (no reflection API in v1)
  4. Remove / narrow UnsupportedRegistry entries for decorated declarations
  5. Add compliance PHPTs under test/compliance/cases/language/attributes_*.phpt

Out of scope: JIT/AOT attribute reflection, #[\Attribute] validation, enum targets.

Implementation hints

Layer Files Notes
Parser vendor/nikic/php-parser AttributeGroup, Attribute nodes
Compiler lib/Compiler.php compileClassLike, compileClassMethod Attach attrGroups to symbol metadata bag
VM lib/VM.php No-op at dispatch
Lint lib/Lint/UnsupportedRegistry.php Drop blocks for decorated Class_ / ClassMethod
Tests test/compliance/cases/language/attribute_class.phpt #[\AllowDynamicProperties] class runs
Tests attribute_method.phpt Method with #[\Deprecated] still callable
CI gate #1904 ATTRIBUTES_COMPLIANCE_GATE=1 after PHPTs green

Suggested PHPT (minimum)

#[\AllowDynamicProperties]
class Box {
    #[\Deprecated]
    public function ping(): string { return 'pong'; }
}
echo (new Box())->ping();
// EXPECT: pong

Acceptance criteria

./script/ci-fast.sh --filter attribute
vendor/bin/phpunit test/compliance/cases/language/attribute_class.phpt

Docker:

docker run --rm -v "$(pwd):/compiler" -w /compiler php-compiler:22.04-dev \
  ./script/ci-fast.sh --filter attribute

Dependencies

Links

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions