Repository navigation
Closed
Labels
IMPORTANTCritical pathCritical patharea:vmVirtual machineVirtual machineenhancementNew feature or requestNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimSpec complete: repro, php-src ref, done-when — safe for workers to claimphase-2:languagePhase 2 – language featuresPhase 2 – language featuresstdlib
Description
Category
language · php-src-strict · PHP 8.4
Problem
PHP 8.4 adds clone($obj, ['prop', ...]) to reinitialize selected properties (notably readonly properties) on the clone. This compiler accepts the syntax on the 8.4 target and executes, but parity vs php-src is unverified:
- Zend 8.2 (Docker reference) rejects parse — expected until 8.4.
- VM runs
clone($w, ['a'])and prints1,2(php-in-php: JIT CloneWithReinitRuntime — shrink clone-with readonly reinit LLVM glue via CloneWithSupport PHP (#1492) #10002 tracks JIT glue only).
Workers need language semantics: which properties re-run default/constructor init, readonly rules, and whether the source object is mutated.
php-src reference
- php/php-src
Zend/zend_clones.c—ZEND_CLONE_WITH, readonly reinit - php/php-src
Zend/zend_compile.c—clonewith second argument parse - RFC: PHP 8.4
clone()with property list
Repro
test/repro/maintainer_gap_clone_with_syntax.php:
<?php
declare(strict_types=1);
class W {
public int $a = 1;
public readonly int $b;
public function __construct() {
$this->b = 2;
}
}
$w = new W();
$w2 = clone($w, ['a']);
echo $w2->a, ',', $w2->b, "\n";Extended state check (add to repro or compliance test):
var_export([$w->a, $w->b, $w2->a, $w2->b]);./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/vm.php test/repro/maintainer_gap_clone_with_syntax.php
'Compare against php-src 8.4 Zend build or upstream Zend/tests/clones/clone_with*.phpt when available.
Scope (PHP-in-PHP)
| Layer | Path |
|---|---|
| Compiler | lib/Compiler.php — clone with property list AST |
| VM | clone opcode + readonly reinit (lib/VM.php, CloneWithSupport) |
| JIT | #10002 CloneWithReinitRuntime — shrink after VM SSOT |
| Tests | test/compliance/cases/language/clone_with_readonly.phpt |
Done when (php-src-strict)
- Repro output matches php-src 8.4 Zend for
$w2property values - Source
$wobject state matches Zend (no spurious mutation) - Invalid property names in list throw/errors per Zend
-
./script/ci-fast.sh --filter clone_withgreen
Related
- php-in-php: JIT CloneWithReinitRuntime — shrink clone-with readonly reinit LLVM glue via CloneWithSupport PHP (#1492) #10002 php-in-PHP JIT glue · php-in-php: JIT ReadonlyRaise — route readonly property write errors through Vm PHP not ~385-line LLVM (#1492) #9522 readonly errors · Epic: Self-host critical path — compiler compiles itself (M3→M5) #1492
Metadata
Metadata
Assignees
Labels
IMPORTANTCritical pathCritical patharea:vmVirtual machineVirtual machineenhancementNew feature or requestNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimSpec complete: repro, php-src ref, done-when — safe for workers to claimphase-2:languagePhase 2 – language featuresPhase 2 – language featuresstdlib
Activity
PurHur commentedon Jun 20, 2026
claim: cursor-agent-lane-c — starting this run (clone-with property list reinit semantics)
Fix clone-with property list to reinitialize defaults (#10310) (#10371)
PurHur commentedon Jun 20, 2026
Merged via #10371.
Fix: Property-list clone-with entries without explicit values (
clone($w, ['a'])) now reinitialize to declared defaults instead of copying the source object's current values.Verification:
array (0 => 99, 1 => 2, 2 => 1, 3 => 2)— source unchanged, clone reinit to defaulta=1