Repository navigation
Closed
Labels
area:compilerCompiler / CFG / JITCompiler / CFG / JITarea: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 features
Description
Category
language · php-src-strict · PHP 8.4
Problem
PHP 8.4 supports clone-with using an array property list in two equivalent forms:
clone($object, ['prop', ...])— works today vialib/Ast/CloneWithDesugar.php(Language: clone with syntax (clone($obj, ['prop'])) — parse fails despite runtime support (PHP 8.4, Zend/zend_language_parser.y) #9743)clone $object with ['prop', ...]— parse fails (unexpected identifier "with")
Runtime support exists (lib/VM/CloneWithSupport.php, CloneWithJitHelper.php) but the keyword + array form never reaches compile.
php-src reference
- php/php-src
Zend/zend_language_parser.y—clone_exprwithwith+ array - php/php-src
Zend/zend_compile.c— property reinit list - php/php-src
Zend/zend_objects.c—zend_objects_clone_obj_with()
Repro (failure today)
Committed: test/repro/maintainer_probe_clone_with_keyword.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 with ['a'];
echo $w2->a, ',', $w2->b, "\n";./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/vm.php test/repro/maintainer_probe_clone_with_keyword.php'
# PhpParser: Syntax error, unexpected identifier "with"Control (passes): test/repro/maintainer_gap_clone_with_syntax.php — clone($w, ['a']) prints 1,2.
Scope (PHP-in-PHP first)
| Path | Work |
|---|---|
lib/Ast/CloneWithDesugar.php |
extend findCloneWithSpan() to accept [...] after with (not only {...} blocks) |
vendor/nikic/php-parser / patches |
if grammar still rejects with keyword, patch overlay per #9743 |
lib/VM/CloneWithSupport.php |
reuse existing reinit window (no new C) |
| Tests | compliance PHPT mirroring maintainer_probe_clone_with_keyword.php |
Done when
- Keyword form compiles and prints
1,2on VM (php-src-strict) - Readonly properties outside the list stay immutable after clone
- Existing
clone($obj, [...])desugar path stays green -
./script/ci-fast.sh --filter clone_withgreen
Related
- Language: clone with syntax (clone($obj, ['prop'])) — parse fails despite runtime support (PHP 8.4, Zend/zend_language_parser.y) #9743 (closed — call form desugar) · Language: clone with — readonly property overrides must succeed during reinit window (zend_objects_clone_obj_with) #7250 readonly reinit · Epic: Self-host critical path — compiler compiles itself (M3→M5) #1492
Metadata
Metadata
Assignees
Labels
area:compilerCompiler / CFG / JITCompiler / CFG / JITarea: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 features
Activity
PurHur commentedon Jun 19, 2026
claim: worker-lane-c — starting this run
Fix clone $obj with ['prop'] keyword array syntax (#9995) (#10036)
PurHur commentedon Jun 19, 2026
Merged via #10036.
Fix:
CloneWithDesugar::findCloneWithSpan()now acceptsclone $obj with ['prop', ...]array property lists (PHP 8.4), reusing the same IIFE lowering asclone($obj, [...]).Verification: