Skip to content

Stdlib: ReflectionClass::getLazyInitializers() — PHP 8.4 lazy init closure list missing (zend_lazy_objects.c) #7320

@PurHur

Description

@PurHur

Summary

PHP 8.4 adds ReflectionClass::getLazyInitializers(): array — returns the list of lazy-initialization closures registered on a class (lazy ghost / hook-backed lazy properties). This compiler implements other lazy-object reflection probes (#6054, #6606, #6885) but not this method.

php-src-strict: return shape and keying must match Zend reflection.

php-src reference

Repro

./script/docker-exec.sh -- php bin/vm.php test/repro-maintainer/lazy_initializers_reflection.php

Current: bool(false) for method_exists(ReflectionClass::class, 'getLazyInitializers')

Expected (Zend PHP 8.4+): method exists; returns array (possibly empty) of Closure instances for lazy initializers on the class.

Implementation (PHP-in-PHP)

  1. Add VM method on builtin ReflectionClass in lib/VM/Builtin/ (mirror ReflectionClassGetLazyPropertyNames pattern from Stdlib: ReflectionClass::getLazyPropertyNames() — PHP 8.4 lazy property introspection missing (ext/reflection/php_reflection.c) #6606).
  2. Read lazy initializer closures from class metadata populated by compiler lazy-object lowering (lib/Compiler/ lazy ghost paths).
  3. Wire JIT/AOT if reflection methods are lowered for self-host.
  4. Compliance .phpt under test/compliance/cases/stdlib/reflection_class_get_lazy_initializers.phpt.

Done when

Links

#6054 · #6606 · #6885 · #1492

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:vmVirtual machineenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-4:stdlibPhase 4 – stdlib for web apps

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions