Skip to content

Language: PHP 8.4 asymmetric visibility private(set) — JIT enforce + catchable Error (phase 2 of #3165) #4029

Description

@PurHur

Category

language

Problem

public private(set) T $prop is enforced on VM (#3165) but JIT either skips the guard or surfaces a non-catchable LogicException instead of Zend’s Error, so scripts using try/catch (Error) diverge.

Capability: docs/capabilities-syntax.md — asymmetric visibility JIT: no.

php-src reference

Repro

<?php
class User {
    public private(set) string $name = 'a';
}
$u = new User();
try {
    $u->name = 'b';
    echo "no error\n";
} catch (Error $e) {
    echo $e->getMessage(), "\n";
}
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh \
  && php bin/vm.php test/repro-maintainer/asymmetric_set.php \
  && php bin/jit.php test/repro-maintainer/asymmetric_set.php'
Mode Behavior
Zend catchable Error: Cannot modify private(set) property User::$name from global scope
VM message printed (fatal path)
JIT uncaught LogicException (not catchable as Error)

Maintainer repro: test/repro-maintainer/asymmetric_set.php
Compliance exists: test/compliance/cases/language/asymmetric_visibility.phpt (VM-only gate in JITTest.php).

Scope

  • lib/JIT/ property write guards (mirror VM asymmetric set visibility)
  • Throw Error (not LogicException) to match Zend
  • Enable JIT compliance row for asymmetric_visibility*.phpt

Done when

  • JIT repro prints the same message via catch (Error)
  • JITTest no longer skips asymmetric_visibility JIT cases
  • ./script/ci-fast.sh --filter asymmetric_visibility green

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:compilerCompiler / CFG / JITarea: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