3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* Challenge 1: Read and write to 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 Intercept { public function getKey($test) { $array = (array) $test; foreach($array as $k => $v) { print_r($k); print_r($v); } } } $intercept = new Intercept; $intercept->getKey($test); // end editing here echo $test->run();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NO3q5
function name:  (null)
number of ops:  13
compiled vars:  !0 = $test, !1 = $intercept
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   42     0  E >   NEW                                              $2      'Test'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   60     3        NEW                                              $5      'Intercept'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !1, $5
   61     6        INIT_METHOD_CALL                                         !1, 'getKey'
          7        SEND_VAR_EX                                              !0
          8        DO_FCALL                                      0          
   66     9        INIT_METHOD_CALL                                         !0, 'run'
         10        DO_FCALL                                      0  $9      
         11        ECHO                                                     $9
         12      > RETURN                                                   1

Class Test:
Function run:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NO3q5
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/NO3q5
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 Intercept:
Function getkey:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 13
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 13
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
filename:       /in/NO3q5
function name:  getKey
number of ops:  15
compiled vars:  !0 = $test, !1 = $array, !2 = $v, !3 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   48     0  E >   RECV                                             !0      
   51     1        CAST                                          7  ~4      !0
          2        ASSIGN                                                   !1, ~4
   52     3      > FE_RESET_R                                       $6      !1, ->13
          4    > > FE_FETCH_R                                       ~7      $6, !2, ->13
          5    >   ASSIGN                                                   !3, ~7
   54     6        INIT_FCALL                                               'print_r'
          7        SEND_VAR                                                 !3
          8        DO_ICALL                                                 
   55     9        INIT_FCALL                                               'print_r'
         10        SEND_VAR                                                 !2
         11        DO_ICALL                                                 
   52    12      > JMP                                                      ->4
         13    >   FE_FREE                                                  $6
   57    14      > RETURN                                                   null

End of function getkey

End of class Intercept.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
186.47 ms | 1392 KiB | 15 Q