Skip to content

Regression: ?? on property hooks invokes get hook when backing initialized (re-#8902, zend_property_hooks.c) #8919

Description

@PurHur

Category

language · regression · php-src-strict

Problem

Closed #8902 required ?? on hooked properties to check backing initialization without calling the get hook. VM regressed (2026-06-16): $c->x ?? 'default' invokes a throwing get hook even when separate backing holds 'a'.

php-src reference

Repro

test/repro/issue_property_hook_coalesce.php:

<?php
class C {
    public string $x {
        get { throw new Exception('get must not run for ??'); }
        set => $this->backing = $value;
    }
    private string $backing = 'a';
}
$c = new C();
var_dump($c->x ?? 'default');
echo "ok\n";
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php test/repro/issue_property_hook_coalesce.php
php bin/vm.php test/repro/issue_property_hook_coalesce.php
'
Runtime Expected Observed
Zend 8.4+ string(1) "a" + ok
VM same Fatal: get must not run for ??

Scope

Done when

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

    area: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