3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* Challenge 1: Modify Test::$secret before it's output. Rules:: 1. No use of Reflection API / runkit extension 2. No stopping execution before Test::run() 3. No Exceptions or PHP errors / warnings notices allowed Hints: 1. Caesar 2. Magic methods 3. Requires a new feature of PHP 5.4 */ class Test { private $secret = 'Nyy lbhe Onfr ner orybat gb hf.'; private $callback; final public function run() { call_user_func($this->callback); return $this->secret . PHP_EOL; } public function __set($k, $v) { $key = $v[($v[$v])]; // $v is some kind of weird array var_dump($key);die; $value = $v(); // and a callback! $this->{$key} = $value; } } $test = new Test; // start editing here class A implements ArrayAccess { private $callCount = 0; public function __call($name, $args){ return function(){ echo "HELLO WORLD"; }; } public function offsetSet($offset, $value) {} public function offsetExists($offset) { return true; } public function offsetUnset($offset) {} public function offsetGet($offset) { $this->callCount++; if ($this->callCount == 1){ $r = $this; } else { $r = "FOO"; } return $r; } } $test->foo = new A; // end editing here echo $test->run();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZhGr2
function name:  (null)
number of ops:  12
compiled vars:  !0 = $test
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   42     0  E >   NEW                                              $1      'Test'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   46     3        DECLARE_CLASS                                            'a'
   78     4        NEW                                              $5      'A'
          5        DO_FCALL                                      0          
          6        ASSIGN_OBJ                                               !0, 'foo'
          7        OP_DATA                                                  $5
   83     8        INIT_METHOD_CALL                                         !0, 'run'
          9        DO_FCALL                                      0  $7      
         10        ECHO                                                     $7
         11      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FZhGr2%3A51%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZhGr2
function name:  {closure}
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   52     0  E >   ECHO                                                     'HELLO+WORLD'
   53     1      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FZhGr2%3A51%240

Class Test:
Function run:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZhGr2
function name:  run
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   FETCH_OBJ_R                                      ~0      'callback'
          1        INIT_USER_CALL                                0          'call_user_func', ~0
          2        DO_FCALL                                      0          
   28     3        FETCH_OBJ_R                                      ~2      'secret'
          4        CONCAT                                           ~3      ~2, '%0A'
          5      > RETURN                                                   ~3
   29     6*     > RETURN                                                   null

End of function run

Function __set:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 79) Position 1 = -2
filename:       /in/ZhGr2
function name:  __set
number of ops:  15
compiled vars:  !0 = $k, !1 = $v, !2 = $key, !3 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   33     2        FETCH_DIM_R                                      ~4      !1, !1
          3        FETCH_DIM_R                                      ~5      !1, ~4
          4        ASSIGN                                                   !2, ~5
   34     5        INIT_FCALL                                               'var_dump'
          6        SEND_VAR                                                 !2
          7        DO_ICALL                                                 
          8      > EXIT                                                     
   35     9*       INIT_DYNAMIC_CALL                                        !1
         10*       DO_FCALL                                      0  $8      
         11*       ASSIGN                                                   !3, $8
   36    12*       ASSIGN_OBJ                                               !2
         13*       OP_DATA                                                  !3
   37    14*     > RETURN                                                   null

End of function __set

End of class Test.

Class A:
Function __call:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZhGr2
function name:  __call
number of ops:  5
compiled vars:  !0 = $name, !1 = $args
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   50     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   51     2        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FZhGr2%3A51%240'
   53     3      > RETURN                                                   ~2
   55     4*     > RETURN                                                   null

End of function __call

Function offsetset:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZhGr2
function name:  offsetSet
number of ops:  3
compiled vars:  !0 = $offset, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   62     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2      > RETURN                                                   null

End of function offsetset

Function offsetexists:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZhGr2
function name:  offsetExists
number of ops:  3
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   63     0  E >   RECV                                             !0      
          1      > RETURN                                                   <true>
          2*     > RETURN                                                   null

End of function offsetexists

Function offsetunset:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZhGr2
function name:  offsetUnset
number of ops:  2
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   64     0  E >   RECV                                             !0      
          1      > RETURN                                                   null

End of function offsetunset

Function offsetget:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 8
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZhGr2
function name:  offsetGet
number of ops:  11
compiled vars:  !0 = $offset, !1 = $r
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   65     0  E >   RECV                                             !0      
   66     1        PRE_INC_OBJ                                              'callCount'
   67     2        FETCH_OBJ_R                                      ~3      'callCount'
          3        IS_EQUAL                                                 ~3, 1
          4      > JMPZ                                                     ~4, ->8
   68     5    >   FETCH_THIS                                       ~5      
          6        ASSIGN                                                   !1, ~5
          7      > JMP                                                      ->9
   70     8    >   ASSIGN                                                   !1, 'FOO'
   73     9    > > RETURN                                                   !1
   74    10*     > RETURN                                                   null

End of function offsetget

End of class A.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
140.46 ms | 1404 KiB | 15 Q