Category
language · php-src-strict
Problem
PHP 8.5 adds clone-with syntax: clone($object, ['prop1', 'prop2']) clones $object and re-initializes only the listed properties from the source (see RFC / php-src clone grammar extension).
This compiler accepts a plain clone $obj but does not parse parenthesized clone-with:
$w2 = clone($w, ['a']); // Zend: selective reinit; VM today: parse error OR wrong lowering
Maintainer repro (test/repro/maintainer_gap_clone_with_syntax.php) shows VM prints 1,2 while Zend rejects with parse error on the comma form — grammar/lowering for clone-with is missing.
php-src reference
Repro
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/vm.php test/repro/maintainer_gap_clone_with_syntax.php 2>&1 | head -3
php test/repro/maintainer_gap_clone_with_syntax.php 2>&1 | head -3
'
| Runtime |
Result |
| Zend PHP 8.5+ |
Parses clone-with; reinit listed props only |
bin/vm.php (today) |
Wrong — legacy clone path or parse failure |
Scope (this repo) — PHP-in-PHP first
| Layer |
Path |
| Parser |
php-cfg / lib/SourcePreprocessor/ — clone ( … , [ … ]) |
| Compiler |
lib/Compiler.php — lower to clone + property reinit op sequence |
| VM |
lib/VM.php — selective property copy from source |
| JIT/AOT |
reuse clone lowering; follow CloneWithJitHelper (#9717) when emit-helper path exists |
| Tests |
new test/compliance/cases/language/clone_with_basic.phpt |
No new C runtime branches — clone-with is compile-time sugar + VM object copy.
Done when
Related
Category
language· php-src-strictProblem
PHP 8.5 adds clone-with syntax:
clone($object, ['prop1', 'prop2'])clones$objectand re-initializes only the listed properties from the source (see RFC / php-srcclonegrammar extension).This compiler accepts a plain
clone $objbut does not parse parenthesized clone-with:Maintainer repro (
test/repro/maintainer_gap_clone_with_syntax.php) shows VM prints1,2while Zend rejects with parse error on the comma form — grammar/lowering for clone-with is missing.php-src reference
Zend/zend_language_parser.y— clone-with productionZend/zend_compile.c— clone lowering + property reinit listZend/zend_closures.c/ object handlers —zend_objects_clone_objselective initRepro
bin/vm.php(today)Scope (this repo) — PHP-in-PHP first
lib/SourcePreprocessor/—clone (…, […])lib/Compiler.php— lower to clone + property reinit op sequencelib/VM.php— selective property copy from sourceCloneWithJitHelper(#9717) when emit-helper path existstest/compliance/cases/language/clone_with_basic.phptNo new C runtime branches — clone-with is compile-time sugar + VM object copy.
Done when
readonlyprops in reinit list follow php-src rules./script/ci-fast.sh --filter clone_withgreenRelated