Skip to content

Language: property hook set hook thrown exceptions must propagate to write site (Zend/zend_property_hooks.c) #9849

Closed

Description

@PurHur

Category

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

Problem

When a property set hook throws, the exception must propagate to the assignment expression (catchable by user try/catch). Zend resumes normal exception flow from $obj->prop = $value.

Symmetric read-site issue: #10309 — get-hook throws on $obj->prop read must propagate to the fetch expression.

class C {
    public int $x {
        get => $this->x;
        set { throw new Exception('set hook'); }
    }
    private int $x = 0;
}
$c = new C();
try {
    $c->x = 1;
    echo "no-resume\n";
} catch (Throwable $e) {
    echo 'caught: ', $e->getMessage(), "\n";
}
// Zend PHP 8.4+: caught: set hook

Blocked today by #9831 (hook + private backing → compile Cannot redeclare C::$x). After #9831 lands, verify set-hook throw/resume semantics.

php-src reference

Repro

Set hook (this issue): test/repro/maintainer_gap_property_hook_set_exception.php

Get hook (#10309): test/repro/maintainer_gap_property_hook_get_throw.php

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/vm.php test/repro/maintainer_gap_property_hook_set_exception.php
php bin/vm.php test/repro/maintainer_gap_property_hook_get_throw.php
'
Engine Set repro Get repro (#10309)
Zend PHP 8.4+ caught: set hook caught: get hook
VM today compile fail (#9831) verify after #9831

Scope (PHP-in-PHP)

Layer Path
VM lib/VM/PropertyHook*.php, read/write opcodes
Compiler #9831 hook + backing compile
JIT #10112 PropertyHookDispatch — VM SSOT first
Tests test/compliance/cases/language/property_hook_set_throw.phpt, property_hook_get_throw.phpt

Done when (php-src-strict)

Related

Activity

  1. added
    enhancementNew feature or request
    area:vmVirtual machine
    implementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claim
    on Jun 19, 2026
  2. PurHur commented on Jun 20, 2026

    @PurHur
    OwnerAuthor

    claim: cursor-agent-lane-a — runtime already green after #9831; adding compliance guard + closing

  3. PurHur commented on Jun 20, 2026

    @PurHur
    OwnerAuthor

    claim released: already fixed — property_hook_set_throw.phpt (#9670) covers set-hook exception propagation; VM repro green.

  4. PurHur commented on Jun 23, 2026

    @PurHur
    OwnerAuthor

    Closing as stale: repro green on master 2026-06-23.

    php bin/vm.php test/repro/maintainer_gap_property_hook_set_exception.php → caught: set hook
    (compliance covered by property_hook_set_throw.phpt per prior claim comment).

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