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 4. No redefining $test 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 $value = $v(); // and a callback! $this->{$key} = $value; } } $test = new Test; // start editing here class Infiltrator implements ArrayAccess { public function __construct($target) { $this->target = $target; } public function sneak($key, $value) { $this->key = $key; $this->value = $value; $this->target->$key = $this; } public function offsetGet($offset) { return $this->key; } public function offsetExists($offset) {} public function offsetSet($offset, $value) {} public function offsetUnset($offset) {} public function __invoke() { return $this->value; } } $infiltrator = new Infiltrator($test); $infiltrator->sneak('callback', function() {}); $infiltrator->sneak('secret', 'I’m in! Send backup!'); // end editing here echo $test->run();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/agjYM
function name:  (null)
number of ops:  21
compiled vars:  !0 = $test, !1 = $infiltrator
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   42     0  E >   NEW                                              $2      'Test'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   46     3        DECLARE_CLASS                                            'infiltrator'
   75     4        NEW                                              $5      'Infiltrator'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !1, $5
   76     8        INIT_METHOD_CALL                                         !1, 'sneak'
          9        SEND_VAL_EX                                              'callback'
         10        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FagjYM%3A76%241'
         11        SEND_VAL_EX                                              ~8
         12        DO_FCALL                                      0          
   77    13        INIT_METHOD_CALL                                         !1, 'sneak'
         14        SEND_VAL_EX                                              'secret'
         15        SEND_VAL_EX                                              'I%E2%80%99m+in%21+Send+backup%21'
         16        DO_FCALL                                      0          
   81    17        INIT_METHOD_CALL                                         !0, 'run'
         18        DO_FCALL                                      0  $11     
         19        ECHO                                                     $11
         20      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FagjYM%3A76%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/agjYM
function name:  {closure}
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   76     0  E > > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FagjYM%3A76%241

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

End of function run

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

End of function __set

End of class Test.

Class Infiltrator:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/agjYM
function name:  __construct
number of ops:  4
compiled vars:  !0 = $target
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   48     0  E >   RECV                                             !0      
   50     1        ASSIGN_OBJ                                               'target'
          2        OP_DATA                                                  !0
   51     3      > RETURN                                                   null

End of function __construct

Function sneak:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/agjYM
function name:  sneak
number of ops:  11
compiled vars:  !0 = $key, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   53     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   55     2        ASSIGN_OBJ                                               'key'
          3        OP_DATA                                                  !0
   56     4        ASSIGN_OBJ                                               'value'
          5        OP_DATA                                                  !1
   57     6        FETCH_THIS                                       ~6      
          7        FETCH_OBJ_W                                      $4      'target'
          8        ASSIGN_OBJ                                               $4, !0
          9        OP_DATA                                                  ~6
   58    10      > RETURN                                                   null

End of function sneak

Function offsetget:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/agjYM
function name:  offsetGet
number of ops:  4
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   60     0  E >   RECV                                             !0      
   62     1        FETCH_OBJ_R                                      ~1      'key'
          2      > RETURN                                                   ~1
   63     3*     > RETURN                                                   null

End of function offsetget

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

End of function offsetexists

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

End of function offsetset

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

End of function offsetunset

Function __invoke:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/agjYM
function name:  __invoke
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   71     0  E >   FETCH_OBJ_R                                      ~0      'value'
          1      > RETURN                                                   ~0
   72     2*     > RETURN                                                   null

End of function __invoke

End of class Infiltrator.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.29 ms | 1394 KiB | 13 Q