3v4l.org

run code in 300+ PHP versions simultaneously
<?php abstract class Expression { protected function escapeStringLiteral(string $value): string { return 'never called'; } } trait ExpressionTrait { protected function escapeStringLiteral(string $value): string { return '\'' . str_replace('\'', '\'\'', $value) . '\''; } } class MyExpression extends Expression { use ExpressionTrait; } class TestExpression extends Expression { private Expression $dummyExpression; public function __construct(Expression $dummyExpression) { $this->dummyExpression = $dummyExpression; } #[\Override] protected function escapeStringLiteral(string $value): string { return $this->dummyExpression->escapeStringLiteral($value); } public function test(): void { var_dump($this->escapeStringLiteral('foo \' bar')); } }; class TestCl { public function test(): void { $exprNoRender = new TestExpression(new MyExpression()); $exprNoRender->test(); } } (new TestCl())->test();
Output for git.master_jit, git.master, rfc.property-hooks
Fatal error: Uncaught Error: Call to protected method MyExpression::escapeStringLiteral() from scope TestExpression in /in/KI9eF:36 Stack trace: #0 /in/KI9eF(41): TestExpression->escapeStringLiteral('foo ' bar') #1 /in/KI9eF(51): TestExpression->test() #2 /in/KI9eF(55): TestCl->test() #3 {main} thrown in /in/KI9eF on line 36
Process exited with code 255.

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:
107.23 ms | 406 KiB | 5 Q