Skip to content

Language: get-only property hook isset/empty must invoke get hook (Zend/zend_property_hooks.c) #9832

Description

@PurHur

Category

language · php-src-strict · PHP 8.4 property hooks

Problem

For a get-only hooked property (no backing field, hook returns a value):

class C {
    public int $x {
        get => 1;
    }
}

Zend routes isset($c->x) and empty($c->x) through the get hook (value 1 → isset true, empty false).

This compiler skips the hook:

  • isset($c->x) → false
  • empty($c->x) → true

Distinct from #9696 (initialized private backing + get/set hooks) which failed compile due to #9830-class redeclare errors.

php-src reference

Repro (failure today)

<?php
class C {
    public int $x {
        get => 1;
    }
}
$c = new C();
var_dump(isset($c->x));
var_dump(empty($c->x));
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/vm.php repro_getonly_hook_isset.php
'
Engine isset empty
Zend PHP 8.4+ true false
VM today false true

Scope

  • lib/VM.php — isset / empty opcodes on hooked properties without backing
  • lib/JIT.php — mirror VM when JIT lowers isset/empty on hooks
  • test/compliance/cases/language/property_hook_getonly_isset_empty.phpt

Done when

  • Repro dumps match Zend on VM
  • ./script/ci-fast.sh --filter property_hook_getonly_isset green

Related

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

    area:vmVirtual machineenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-2:languagePhase 2 – language featuresstdlib

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions