Skip to content

Language: public private(set) property — parse accepted, Zend rejects multiple access modifiers (Zend/zend_compile.c) #16142

Description

@PurHur

Category

language · php-src-strict · PHP 8.4 asymmetric visibility

Problem

Combining explicit public with private(set) on the same property is a parse/compile error in Zend ("Multiple access type modifiers are not allowed"). This compiler accepts the declaration and runs user code.

Repro Zend 8.2+ VM (2026-07-04)
public private(set) string \$x; parse error (multiple access modifiers) compiles; echoes hi then Error on external write

php-src reference

PHP implementation target

  • lib/Compiler.php / parser — reject public + private(set) / protected(set) combinations at parse or compile time
  • lib/ property visibility lowering — do not treat as valid asymmetric visibility until grammar matches php-src

Repro

./script/docker-exec.sh -- php bin/vm.php test/repro/maintainer_gap_asymmetric_visibility_public_private_set.php

Done when

  • Repro fails at parse/compile with Zend-equivalent diagnostic (not runtime Error on valid-looking code)
  • Compliance .phpt guard under test/compliance/cases/language/
  • php-src-strict; no php-compiler-strict shortcut

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