• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

KarpelesLab / goro / 26391575478

25 May 2026 08:38AM UTC coverage: 12.556% (+0.03%) from 12.531%
26391575478

push

github

MagicalTux
vm: lower \$obj->n++/--, Foo::\$x++/-- inc/dec to OP_INC_DEC_OBJ/STATIC_PROP

Inc/dec on object and static properties were delegated to the AST
runner via emitAssignViaAST. They now lower to two dedicated opcodes
mirroring the OBJECT_COMPOUND_ASSIGN / STATIC_PROP_COMPOUND_ASSIGN
pattern just landed:

OP_INC_DEC_OBJ_PROP encoding:
  A = const-pool prop-name index (ZString)
  B bit 0 = inc (1) vs dec (0)
  B bit 1 = post (1) vs pre (0)
  C bit 0 = keep-value-on-stack (expr ctx)
Stack: pops receiver. Reads cur via objectGet, applies
compiler.DoInc (string-increment, NULL->1), writes back via
objectSet. Pushes pre/post-mutation value when keep-flag is set.

OP_INC_DEC_STATIC_PROP — same encoding, pops class-source. Read +
write through EvalClassStaticVarRead / AssignClassStaticProp.

Only the static-name, non-nullsafe shape goes native; dynamic-name
\$obj->{\$x}++ and nullsafe \$obj?->prop++ are not valid as ++/-- targets
in PHP, but the emit still falls back to AST for parity. Array
\$arr[\$k]++ continues to delegate.

Verified locally:
  - \$f->n++/--, ++/--\$f->n stmt and expr ctx (10 -> 11 -> 12 -> …)
  - Foo::\$s++/--, ++/--Foo::\$s stmt and expr ctx
  - LSB: static::\$cnt++ inside method picks up the called class
    (P::bump() bumps P::\$cnt, C::bump() bumps C::\$cnt)
  - typed props (int) keep their declared type after ++
  - existing \$obj->prop += test still passes

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

100 of 136 new or added lines in 3 files covered. (73.53%)

50 existing lines in 4 files now uncovered.

14911 of 118753 relevant lines covered (12.56%)

2574.43 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

13.25
/core/phpobj/zclass.go


Source Not Available

STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc