Skip to content

Language: static property hooks (PHP 8.4) — compile + get/set dispatch parity (Zend/zend_property_hooks.c) #9520

Description

@PurHur

Category

language · php-src-strict (PHP 8.4)

Problem

PHP 8.4 adds static property hooks (public static int $n { get => ...; set => ...; }). This compiler parses and runs a subset (see test/repro/issue_4807_static_property_hook_jit.php), but behavior is unverified vs php-src 8.4 and JIT/AOT paths are missing. Zend 8.2 in harness correctly rejects the syntax; parity target is php-src master 8.4 semantics.

php-src reference

Repro

In-tree: test/repro/issue_4807_static_property_hook_jit.php

<?php
class Counter {
    public static int $n {
        get => self::$n;
        set => self::$n = $value * 2;
    }
}
Counter::$n = 3;
echo Counter::$n, "\n";
# Compare against php-src 8.4+ build when available; interim VM audit:
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/vm.php test/repro/issue_4807_static_property_hook_jit.php
php bin/jit.php test/repro/issue_4807_static_property_hook_jit.php 2>&1 | head -5
'
Step Expected (php-src 8.4) VM today
Counter::$n = 3 set hook runs ($value * 2 → stores 6) prints 6 on VM (audit set hook)
JIT same as VM verify / file gap

Scope (this repo)

Path Work
lib/Compiler.php Static hooked property metadata + read/write lowering
lib/VM/PropertyHookSupport.php Static get/set dispatch (mirror instance hooks #4687)
lib/JIT/ Hook calls on static property access (or explicit VM-only deferral)
Tests test/compliance/cases/language/static_property_hooks.phpt

PHP-in-PHP: hook bodies compiled through existing pipeline; no new runtime/*.c.

Done when

  • Repro output matches php-src 8.4 reference on VM (set hook doubles: 6)
  • unset/inheritance/typed-static edge cases from php-src tests covered or linked as follow-ups
  • JIT documented green or follow-up issue filed with repro
  • ./script/ci-fast.sh --filter static_property_hooks green

Related: instance hooks #4687, #6427, Reflection raw access #6451. Ref: #1492

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

    IMPORTANTCritical patharea:vmVirtual machineenhancementNew feature or requestimplementation-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