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 $value = $v(); // and a callback! $this->{$key} = $value; } } $test = new Test; // start editing here function decode($N,$alphabet,$msg){ // Initialization $M = count($alphabet); $decrypt = array(); $decode = array(); $encrypted = preg_split("//",$msg, -1, PREG_SPLIT_NO_EMPTY); // Compute the decoding map $decode[' '] = ' '; foreach ($alphabet as $n=>$v){ $decode[$v] = $alphabet[($M+($n-$N)) % $M]; // Compute the decoding map for $v } foreach ($encrypted as $v){ $decrypt[] = $decode[$v]; } return join('',$decrypt); } $array = (array) $test; reset($array); $first_key = key($array); print_r($array[$first_key]); //used this to figure out the count: // http://rumkin.com/tools/cipher/caesar.php $key = decode(13,25, $array[$first_key]); // end editing here echo $test->run();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/r9DH2
function name:  (null)
number of ops:  27
compiled vars:  !0 = $test, !1 = $array, !2 = $first_key, !3 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   41     0  E >   NEW                                              $4      'Test'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $4
   68     3        CAST                                          7  ~7      !0
          4        ASSIGN                                                   !1, ~7
   70     5        INIT_FCALL                                               'reset'
          6        SEND_REF                                                 !1
          7        DO_ICALL                                                 
   71     8        INIT_FCALL                                               'key'
          9        SEND_VAR                                                 !1
         10        DO_ICALL                                         $10     
         11        ASSIGN                                                   !2, $10
   73    12        INIT_FCALL                                               'print_r'
         13        FETCH_DIM_R                                      ~12     !1, !2
         14        SEND_VAL                                                 ~12
         15        DO_ICALL                                                 
   77    16        INIT_FCALL                                               'decode'
         17        SEND_VAL                                                 13
         18        SEND_VAL                                                 25
         19        FETCH_DIM_R                                      ~14     !1, !2
         20        SEND_VAL                                                 ~14
         21        DO_FCALL                                      0  $15     
         22        ASSIGN                                                   !3, $15
   82    23        INIT_METHOD_CALL                                         !0, 'run'
         24        DO_FCALL                                      0  $17     
         25        ECHO                                                     $17
         26      > RETURN                                                   1

Function decode:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 17, Position 2 = 26
Branch analysis from position: 17
2 jumps found. (Code = 78) Position 1 = 18, Position 2 = 26
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
Branch analysis from position: 26
2 jumps found. (Code = 77) Position 1 = 28, Position 2 = 33
Branch analysis from position: 28
2 jumps found. (Code = 78) Position 1 = 29, Position 2 = 33
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 33
Branch analysis from position: 26
filename:       /in/r9DH2
function name:  decode
number of ops:  40
compiled vars:  !0 = $N, !1 = $alphabet, !2 = $msg, !3 = $M, !4 = $decrypt, !5 = $decode, !6 = $encrypted, !7 = $v, !8 = $n
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   45     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   49     3        COUNT                                            ~9      !1
          4        ASSIGN                                                   !3, ~9
   50     5        ASSIGN                                                   !4, <array>
   51     6        ASSIGN                                                   !5, <array>
   53     7        INIT_FCALL                                               'preg_split'
          8        SEND_VAL                                                 '%2F%2F'
          9        SEND_VAR                                                 !2
         10        SEND_VAL                                                 -1
         11        SEND_VAL                                                 1
         12        DO_ICALL                                         $13     
         13        ASSIGN                                                   !6, $13
   56    14        ASSIGN_DIM                                               !5, '+'
         15        OP_DATA                                                  '+'
   57    16      > FE_RESET_R                                       $16     !1, ->26
         17    > > FE_FETCH_R                                       ~17     $16, !7, ->26
         18    >   ASSIGN                                                   !8, ~17
   58    19        SUB                                              ~20     !8, !0
         20        ADD                                              ~21     !3, ~20
         21        MOD                                              ~22     ~21, !3
         22        FETCH_DIM_R                                      ~23     !1, ~22
         23        ASSIGN_DIM                                               !5, !7
         24        OP_DATA                                                  ~23
   57    25      > JMP                                                      ->17
         26    >   FE_FREE                                                  $16
   61    27      > FE_RESET_R                                       $24     !6, ->33
         28    > > FE_FETCH_R                                               $24, !7, ->33
   62    29    >   FETCH_DIM_R                                      ~26     !5, !7
         30        ASSIGN_DIM                                               !4
         31        OP_DATA                                                  ~26
   61    32      > JMP                                                      ->28
         33    >   FE_FREE                                                  $24
   65    34        INIT_FCALL                                               'join'
         35        SEND_VAL                                                 ''
         36        SEND_VAR                                                 !4
         37        DO_ICALL                                         $27     
         38      > RETURN                                                   $27
   66    39*     > RETURN                                                   null

End of function decode

Class Test:
Function run:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/r9DH2
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 = 62) Position 1 = -2
filename:       /in/r9DH2
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
-------------------------------------------------------------------------------------
   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_DYNAMIC_CALL                                        !1
          6        DO_FCALL                                      0  $7      
          7        ASSIGN                                                   !3, $7
   35     8        ASSIGN_OBJ                                               !2
          9        OP_DATA                                                  !3
   36    10      > RETURN                                                   null

End of function __set

End of class Test.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.52 ms | 1407 KiB | 24 Q