3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Immutable { public function __construct(/** @psalm-readonly */ public stdClass $neverChange) {} public function mutate(): void { $this->neverChange->foo = 1; } } class DoOtherStuff { public function doStuff(Immutable $immutable): void { $immutable->mutate(); } } $data = new stdClass; $data->foo = 0; $immutable = new Immutable($data); /* ... */ if ($immutable->neverChange->foo === 0) { /* ... */ (new DoOtherStuff())->doStuff($immutable); /* Here I would assume, that my immutable object still holds the not change value stdClass::foo = 0 but it got mutated to stdClass::foo = 1 */ } echo "Does this code actually run without any syntax errors? " . ($immutable->neverChange->foo ? 'Me definetly think so...' : 'No, some internet rando was smarter than me rapid typing some example which everybody did understand anyways');
Output for git.master, git.master_jit, rfc.property-hooks
Does this code actually run without any syntax errors? Me definetly think so...

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
31.85 ms | 405 KiB | 5 Q