Skip to content

Language: $obj->n++ with __get/__set warns Undefined property — Zend silent magic (zend_object_handlers.c) #31992

Description

@PurHur

Category

Language · php-src-strict / magic property increment

Problem

$obj->n++ when n is not a declared property and the class implements __get/__set must go through magic (Zend zend_std_get_property_ptr_ptr + __get/__set) without Undefined property. The VM already calls __get/__set and the stored value matches (inc=2), but it also emits Warning: Undefined property: M::$n from the #29241 BP_VAR_RW path (warnUndefinedPropertyAfterIncDecRwFetch). That warning is for a missing plain property, not a magic one.

+= on the same object is already silent (parity OK). Inverse of closed #29241 (omit warning when there is no __get).

Probed 2026-08-18 @ aa2e5e8b62 — Zend 8.2.32 vs php bin/vm.php / php bin/jit.php.

Repro Zend 8.2.32 VM / JIT
$m->n++ with __get/__set backing n=>1 inc=2, no warning inc=2 + Undefined property: M::$n
$m->n += 2 on the same class plus=3, no warning plus=3, no warning (parity OK)

php-src reference

PHP implementation target

Repro

./script/docker-exec.sh -- bash -lc 'php bin/vm.php test/repro/maintainer_gap_magic_prop_inc.php'
./script/docker-exec.sh -- bash -lc 'php test/repro/maintainer_gap_magic_prop_inc.php'

Done when

  • VM prints inc=2 with no Undefined property warning (matches Zend)
  • JIT/AOT same (or documented skip with reason)
  • Compliance .phpt 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 machinebugSomething isn't workingimplementation-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