3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A {protected $a = 'A'; /*public function __get($f){ return 'field_'.$f; }*/} class B1 extends A {} class B2 extends A {protected $a = 'B';} class C extends A { public function foo(A $a) { echo $a->a; // will fail depends on $a implementation // liskov substitution principle failed } } $a = new A(); $b1 = new B1(); $b2 = new B2(); $c = new C(); $c->foo($b1); // ok $c->foo($b2); // not ok?
Output for git.master, git.master_jit, rfc.property-hooks
A Fatal error: Uncaught Error: Cannot access protected property B2::$a in /in/OibCN:8 Stack trace: #0 /in/OibCN(17): C->foo(Object(B2)) #1 {main} thrown in /in/OibCN on line 8
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:
33.33 ms | 401 KiB | 8 Q