3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function mimicking($obj, $exec){ var_dump(debug_backtrace()); return (function() use($exec){ return $exec(); })->bindTo(null, $obj)(); } class A{ protected $stuff = 10; function test(){ return new class($this){ function __construct(A $s){ $this->s = $s; } function asd(){ return mimicking($this->s, function(){ return $this->s->stuff; }); } }; } } $x = new A; echo $x->test()->asd();
based on ALDal
Output for 7.2.0
array(2) { [0]=> array(4) { ["file"]=> string(9) "/in/m479s" ["line"]=> int(20) ["function"]=> string(9) "mimicking" ["args"]=> array(2) { [0]=> object(A)#1 (1) { ["stuff":protected]=> int(10) } [1]=> object(Closure)#3 (1) { ["this"]=> object(class@anonymous)#2 (1) { ["s"]=> object(A)#1 (1) { ["stuff":protected]=> int(10) } } } } } [1]=> array(7) { ["file"]=> string(9) "/in/m479s" ["line"]=> int(27) ["function"]=> string(3) "asd" ["class"]=> string(39) "class@anonymous/in/m479s0x7f3c2222c1fd" ["object"]=> object(class@anonymous)#2 (1) { ["s"]=> object(A)#1 (1) { ["stuff":protected]=> int(10) } } ["type"]=> string(2) "->" ["args"]=> array(0) { } } } Fatal error: Uncaught Error: Cannot access protected property A::$stuff in /in/m479s:19 Stack trace: #0 /in/m479s(6): class@anonymous->{closure}() #1 /in/m479s(7): A::{closure}() #2 /in/m479s(20): mimicking(Object(A), Object(Closure)) #3 /in/m479s(27): class@anonymous->asd() #4 {main} thrown in /in/m479s on line 19
Process exited with code 255.
Output for 7.1.10
array(2) { [0]=> array(4) { ["file"]=> string(9) "/in/m479s" ["line"]=> int(20) ["function"]=> string(9) "mimicking" ["args"]=> array(2) { [0]=> object(A)#1 (1) { ["stuff":protected]=> int(10) } [1]=> object(Closure)#3 (1) { ["this"]=> object(class@anonymous)#2 (1) { ["s"]=> object(A)#1 (1) { ["stuff":protected]=> int(10) } } } } } [1]=> array(7) { ["file"]=> string(9) "/in/m479s" ["line"]=> int(27) ["function"]=> string(3) "asd" ["class"]=> string(39) "class@anonymous/in/m479s0x7f7772cdc1fd" ["object"]=> object(class@anonymous)#2 (1) { ["s"]=> object(A)#1 (1) { ["stuff":protected]=> int(10) } } ["type"]=> string(2) "->" ["args"]=> array(0) { } } } Fatal error: Uncaught Error: Cannot access protected property A::$stuff in /in/m479s:19 Stack trace: #0 /in/m479s(6): class@anonymous->{closure}() #1 /in/m479s(7): A::{closure}() #2 /in/m479s(20): mimicking(Object(A), Object(Closure)) #3 /in/m479s(27): class@anonymous->asd() #4 {main} thrown in /in/m479s on line 19
Process exited with code 255.
Output for 7.1.7
array(2) { [0]=> array(4) { ["file"]=> string(9) "/in/m479s" ["line"]=> int(20) ["function"]=> string(9) "mimicking" ["args"]=> array(2) { [0]=> object(A)#1 (1) { ["stuff":protected]=> int(10) } [1]=> object(Closure)#3 (1) { ["this"]=> object(class@anonymous)#2 (1) { ["s"]=> object(A)#1 (1) { ["stuff":protected]=> int(10) } } } } } [1]=> array(7) { ["file"]=> string(9) "/in/m479s" ["line"]=> int(27) ["function"]=> string(3) "asd" ["class"]=> string(39) "class@anonymous/in/m479s0x7fd85263b1fd" ["object"]=> object(class@anonymous)#2 (1) { ["s"]=> object(A)#1 (1) { ["stuff":protected]=> int(10) } } ["type"]=> string(2) "->" ["args"]=> array(0) { } } } Fatal error: Uncaught Error: Cannot access protected property A::$stuff in /in/m479s:19 Stack trace: #0 /in/m479s(6): class@anonymous->{closure}() #1 /in/m479s(7): A::{closure}() #2 /in/m479s(20): mimicking(Object(A), Object(Closure)) #3 /in/m479s(27): class@anonymous->asd() #4 {main} thrown in /in/m479s on line 19
Process exited with code 255.
Output for 7.1.6
array(2) { [0]=> array(4) { ["file"]=> string(9) "/in/m479s" ["line"]=> int(20) ["function"]=> string(9) "mimicking" ["args"]=> array(2) { [0]=> object(A)#1 (1) { ["stuff":protected]=> int(10) } [1]=> object(Closure)#3 (1) { ["this"]=> object(class@anonymous)#2 (1) { ["s"]=> object(A)#1 (1) { ["stuff":protected]=> int(10) } } } } } [1]=> array(7) { ["file"]=> string(9) "/in/m479s" ["line"]=> int(27) ["function"]=> string(3) "asd" ["class"]=> string(39) "class@anonymous/in/m479s0x7f617abe01fd" ["object"]=> object(class@anonymous)#2 (1) { ["s"]=> object(A)#1 (1) { ["stuff":protected]=> int(10) } } ["type"]=> string(2) "->" ["args"]=> array(0) { } } } Fatal error: Uncaught Error: Cannot access protected property A::$stuff in /in/m479s:19 Stack trace: #0 /in/m479s(6): class@anonymous->{closure}() #1 /in/m479s(7): A::{closure}() #2 /in/m479s(20): mimicking(Object(A), Object(Closure)) #3 /in/m479s(27): class@anonymous->asd() #4 {main} thrown in /in/m479s on line 19
Process exited with code 255.
Output for 7.1.5
array(2) { [0]=> array(4) { ["file"]=> string(9) "/in/m479s" ["line"]=> int(20) ["function"]=> string(9) "mimicking" ["args"]=> array(2) { [0]=> object(A)#1 (1) { ["stuff":protected]=> int(10) } [1]=> object(Closure)#3 (1) { ["this"]=> object(class@anonymous)#2 (1) { ["s"]=> object(A)#1 (1) { ["stuff":protected]=> int(10) } } } } } [1]=> array(7) { ["file"]=> string(9) "/in/m479s" ["line"]=> int(27) ["function"]=> string(3) "asd" ["class"]=> string(39) "class@anonymous/in/m479s0x7fd1e295f1fd" ["object"]=> object(class@anonymous)#2 (1) { ["s"]=> object(A)#1 (1) { ["stuff":protected]=> int(10) } } ["type"]=> string(2) "->" ["args"]=> array(0) { } } } Fatal error: Uncaught Error: Cannot access protected property A::$stuff in /in/m479s:19 Stack trace: #0 /in/m479s(6): class@anonymous->{closure}() #1 /in/m479s(7): A::{closure}() #2 /in/m479s(20): mimicking(Object(A), Object(Closure)) #3 /in/m479s(27): class@anonymous->asd() #4 {main} thrown in /in/m479s on line 19
Process exited with code 255.
Output for 7.1.0
array(2) { [0]=> array(4) { ["file"]=> string(9) "/in/m479s" ["line"]=> int(20) ["function"]=> string(9) "mimicking" ["args"]=> array(2) { [0]=> object(A)#1 (1) { ["stuff":protected]=> int(10) } [1]=> object(Closure)#3 (1) { ["this"]=> object(class@anonymous)#2 (1) { ["s"]=> object(A)#1 (1) { ["stuff":protected]=> int(10) } } } } } [1]=> array(7) { ["file"]=> string(9) "/in/m479s" ["line"]=> int(27) ["function"]=> string(3) "asd" ["class"]=> string(39) "class@anonymous/in/m479s0x7fe187bd11fd" ["object"]=> object(class@anonymous)#2 (1) { ["s"]=> object(A)#1 (1) { ["stuff":protected]=> int(10) } } ["type"]=> string(2) "->" ["args"]=> array(0) { } } } Fatal error: Uncaught Error: Cannot access protected property A::$stuff in /in/m479s:19 Stack trace: #0 /in/m479s(6): class@anonymous->{closure}() #1 /in/m479s(7): A::{closure}() #2 /in/m479s(20): mimicking(Object(A), Object(Closure)) #3 /in/m479s(27): class@anonymous->asd() #4 {main} thrown in /in/m479s on line 19
Process exited with code 255.
Output for 7.0.20
array(2) { [0]=> array(4) { ["file"]=> string(9) "/in/m479s" ["line"]=> int(20) ["function"]=> string(9) "mimicking" ["args"]=> array(2) { [0]=> object(A)#1 (1) { ["stuff":protected]=> int(10) } [1]=> object(Closure)#3 (1) { ["this"]=> object(class@anonymous)#2 (1) { ["s"]=> object(A)#1 (1) { ["stuff":protected]=> int(10) } } } } } [1]=> array(7) { ["file"]=> string(9) "/in/m479s" ["line"]=> int(27) ["function"]=> string(3) "asd" ["class"]=> string(39) "class@anonymous/in/m479s0x7f7d600b61fd" ["object"]=> object(class@anonymous)#2 (1) { ["s"]=> object(A)#1 (1) { ["stuff":protected]=> int(10) } } ["type"]=> string(2) "->" ["args"]=> array(0) { } } } Fatal error: Uncaught Error: Cannot access protected property A::$stuff in /in/m479s:19 Stack trace: #0 /in/m479s(6): class@anonymous->{closure}() #1 /in/m479s(7): A::{closure}() #2 /in/m479s(20): mimicking(Object(A), Object(Closure)) #3 /in/m479s(27): class@anonymous->asd() #4 {main} thrown in /in/m479s on line 19
Process exited with code 255.
Output for 7.0.6
array(2) { [0]=> array(4) { ["file"]=> string(9) "/in/m479s" ["line"]=> int(20) ["function"]=> string(9) "mimicking" ["args"]=> array(2) { [0]=> object(A)#1 (1) { ["stuff":protected]=> int(10) } [1]=> object(Closure)#3 (1) { ["this"]=> object(class@anonymous)#2 (1) { ["s"]=> object(A)#1 (1) { ["stuff":protected]=> int(10) } } } } } [1]=> array(7) { ["file"]=> string(9) "/in/m479s" ["line"]=> int(27) ["function"]=> string(3) "asd" ["class"]=> string(39) "class@anonymous/in/m479s0x7f70cc78e1fd" ["object"]=> object(class@anonymous)#2 (1) { ["s"]=> object(A)#1 (1) { ["stuff":protected]=> int(10) } } ["type"]=> string(2) "->" ["args"]=> array(0) { } } } Fatal error: Uncaught Error: Cannot access protected property A::$stuff in /in/m479s:19 Stack trace: #0 /in/m479s(6): class@anonymous->{closure}() #1 /in/m479s(7): A::{closure}() #2 /in/m479s(20): mimicking(Object(A), Object(Closure)) #3 /in/m479s(27): class@anonymous->asd() #4 {main} thrown in /in/m479s on line 19
Process exited with code 255.
Output for 7.0.5
array(2) { [0]=> array(4) { ["file"]=> string(9) "/in/m479s" ["line"]=> int(20) ["function"]=> string(9) "mimicking" ["args"]=> array(2) { [0]=> object(A)#1 (1) { ["stuff":protected]=> int(10) } [1]=> object(Closure)#3 (1) { ["this"]=> object(class@anonymous)#2 (1) { ["s"]=> object(A)#1 (1) { ["stuff":protected]=> int(10) } } } } } [1]=> array(7) { ["file"]=> string(9) "/in/m479s" ["line"]=> int(27) ["function"]=> string(3) "asd" ["class"]=> string(39) "class@anonymous/in/m479s0x7f09227481fd" ["object"]=> object(class@anonymous)#2 (1) { ["s"]=> object(A)#1 (1) { ["stuff":protected]=> int(10) } } ["type"]=> string(2) "->" ["args"]=> array(0) { } } } Fatal error: Uncaught Error: Cannot access protected property A::$stuff in /in/m479s:19 Stack trace: #0 /in/m479s(6): class@anonymous->{closure}() #1 /in/m479s(7): A::{closure}() #2 /in/m479s(20): mimicking(Object(A), Object(Closure)) #3 /in/m479s(27): class@anonymous->asd() #4 {main} thrown in /in/m479s on line 19
Process exited with code 255.
Output for 7.0.4
array(2) { [0]=> array(4) { ["file"]=> string(9) "/in/m479s" ["line"]=> int(20) ["function"]=> string(9) "mimicking" ["args"]=> array(2) { [0]=> object(A)#1 (1) { ["stuff":protected]=> int(10) } [1]=> object(Closure)#3 (1) { ["this"]=> object(class@anonymous)#2 (1) { ["s"]=> object(A)#1 (1) { ["stuff":protected]=> int(10) } } } } } [1]=> array(7) { ["file"]=> string(9) "/in/m479s" ["line"]=> int(27) ["function"]=> string(3) "asd" ["class"]=> string(39) "class@anonymous/in/m479s0x7f8d0f8a21fd" ["object"]=> object(class@anonymous)#2 (1) { ["s"]=> object(A)#1 (1) { ["stuff":protected]=> int(10) } } ["type"]=> string(2) "->" ["args"]=> array(0) { } } } Fatal error: Uncaught Error: Cannot access protected property A::$stuff in /in/m479s:19 Stack trace: #0 /in/m479s(6): class@anonymous->{closure}() #1 /in/m479s(7): A::{closure}() #2 /in/m479s(20): mimicking(Object(A), Object(Closure)) #3 /in/m479s(27): class@anonymous->asd() #4 {main} thrown in /in/m479s on line 19
Process exited with code 255.
Output for 7.0.3
array(2) { [0]=> array(4) { ["file"]=> string(9) "/in/m479s" ["line"]=> int(20) ["function"]=> string(9) "mimicking" ["args"]=> array(2) { [0]=> object(A)#1 (1) { ["stuff":protected]=> int(10) } [1]=> object(Closure)#3 (1) { ["this"]=> object(class@anonymous)#2 (1) { ["s"]=> object(A)#1 (1) { ["stuff":protected]=> int(10) } } } } } [1]=> array(7) { ["file"]=> string(9) "/in/m479s" ["line"]=> int(27) ["function"]=> string(3) "asd" ["class"]=> string(39) "class@anonymous/in/m479s0x7ff8536a21fd" ["object"]=> object(class@anonymous)#2 (1) { ["s"]=> object(A)#1 (1) { ["stuff":protected]=> int(10) } } ["type"]=> string(2) "->" ["args"]=> array(0) { } } } Fatal error: Uncaught Error: Cannot access protected property A::$stuff in /in/m479s:19 Stack trace: #0 /in/m479s(6): class@anonymous->{closure}() #1 /in/m479s(7): A::{closure}() #2 /in/m479s(20): mimicking(Object(A), Object(Closure)) #3 /in/m479s(27): class@anonymous->asd() #4 {main} thrown in /in/m479s on line 19
Process exited with code 255.
Output for 7.0.2
array(2) { [0]=> array(4) { ["file"]=> string(9) "/in/m479s" ["line"]=> int(20) ["function"]=> string(9) "mimicking" ["args"]=> array(2) { [0]=> object(A)#1 (1) { ["stuff":protected]=> int(10) } [1]=> object(Closure)#3 (1) { ["this"]=> object(class@anonymous)#2 (1) { ["s"]=> object(A)#1 (1) { ["stuff":protected]=> int(10) } } } } } [1]=> array(7) { ["file"]=> string(9) "/in/m479s" ["line"]=> int(27) ["function"]=> string(3) "asd" ["class"]=> string(39) "class@anonymous/in/m479s0x7f63878711fd" ["object"]=> object(class@anonymous)#2 (1) { ["s"]=> object(A)#1 (1) { ["stuff":protected]=> int(10) } } ["type"]=> string(2) "->" ["args"]=> array(0) { } } } Fatal error: Uncaught Error: Cannot access protected property A::$stuff in /in/m479s:19 Stack trace: #0 /in/m479s(6): class@anonymous->{closure}() #1 /in/m479s(7): A::{closure}() #2 /in/m479s(20): mimicking(Object(A), Object(Closure)) #3 /in/m479s(27): class@anonymous->asd() #4 {main} thrown in /in/m479s on line 19
Process exited with code 255.
Output for 7.0.1
array(2) { [0]=> array(4) { ["file"]=> string(9) "/in/m479s" ["line"]=> int(20) ["function"]=> string(9) "mimicking" ["args"]=> array(2) { [0]=> object(A)#1 (1) { ["stuff":protected]=> int(10) } [1]=> object(Closure)#3 (1) { ["this"]=> object(class@anonymous)#2 (1) { ["s"]=> object(A)#1 (1) { ["stuff":protected]=> int(10) } } } } } [1]=> array(7) { ["file"]=> string(9) "/in/m479s" ["line"]=> int(27) ["function"]=> string(3) "asd" ["class"]=> string(39) "class@anonymous/in/m479s0x7fc6199941fd" ["object"]=> object(class@anonymous)#2 (1) { ["s"]=> object(A)#1 (1) { ["stuff":protected]=> int(10) } } ["type"]=> string(2) "->" ["args"]=> array(0) { } } } Fatal error: Uncaught Error: Cannot access protected property A::$stuff in /in/m479s:19 Stack trace: #0 /in/m479s(6): class@anonymous->{closure}() #1 /in/m479s(7): A::{closure}() #2 /in/m479s(20): mimicking(Object(A), Object(Closure)) #3 /in/m479s(27): class@anonymous->asd() #4 {main} thrown in /in/m479s on line 19
Process exited with code 255.
Output for 7.0.0
array(2) { [0]=> array(4) { ["file"]=> string(9) "/in/m479s" ["line"]=> int(20) ["function"]=> string(9) "mimicking" ["args"]=> array(2) { [0]=> object(A)#1 (1) { ["stuff":protected]=> int(10) } [1]=> object(Closure)#3 (1) { ["this"]=> object(class@anonymous)#2 (1) { ["s"]=> object(A)#1 (1) { ["stuff":protected]=> int(10) } } } } } [1]=> array(7) { ["file"]=> string(9) "/in/m479s" ["line"]=> int(27) ["function"]=> string(3) "asd" ["class"]=> string(39) "class@anonymous/in/m479s0x7ff5bb6761fd" ["object"]=> object(class@anonymous)#2 (1) { ["s"]=> object(A)#1 (1) { ["stuff":protected]=> int(10) } } ["type"]=> string(2) "->" ["args"]=> array(0) { } } } Fatal error: Uncaught Error: Cannot access protected property A::$stuff in /in/m479s:19 Stack trace: #0 /in/m479s(6): class@anonymous->{closure}() #1 /in/m479s(7): A::{closure}() #2 /in/m479s(20): mimicking(Object(A), Object(Closure)) #3 /in/m479s(27): class@anonymous->asd() #4 {main} thrown in /in/m479s on line 19
Process exited with code 255.
Output for 5.4.12 - 5.6.28
Parse error: syntax error, unexpected '->' (T_OBJECT_OPERATOR) in /in/m479s on line 7
Process exited with code 255.
Output for 5.3.22 - 5.3.29
Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /in/m479s on line 7
Process exited with code 255.