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 class foo implements ArrayAccess { private $bar = array('a', 'b', 'callback', 'time', 'c', 'secret', 'whatever'); public function offsetExists ( $offset ) { return true; } public function offsetGet ( $offset ) { return next($this->bar); } public function offsetSet ( $offset, $value ) { } public function offsetUnset ( $offset ) { } public function __invoke() { return next($this->bar); } } $tree = new foo(); $test->hack = $tree; // end editing here echo $test->run();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jWVB4
function name:  (null)
number of ops:  13
compiled vars:  !0 = $test, !1 = $tree
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   41     0  E >   NEW                                              $2      'Test'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   45     3        DECLARE_CLASS                                            'foo'
   57     4        NEW                                              $5      'foo'
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !1, $5
   58     7        ASSIGN_OBJ                                               !0, 'hack'
          8        OP_DATA                                                  !1
   62     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/jWVB4
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/jWVB4
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.

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

End of function offsetexists

Function offsetget:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jWVB4
function name:  offsetGet
number of ops:  7
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   50     0  E >   RECV                                             !0      
          1        INIT_FCALL                                               'next'
          2        FETCH_OBJ_W                                      $1      'bar'
          3        SEND_REF                                                 $1
          4        DO_ICALL                                         $2      
          5      > RETURN                                                   $2
          6*     > RETURN                                                   null

End of function offsetget

Function offsetset:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jWVB4
function name:  offsetSet
number of ops:  3
compiled vars:  !0 = $offset, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   51     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/jWVB4
function name:  offsetUnset
number of ops:  2
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   52     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/jWVB4
function name:  __invoke
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   54     0  E >   INIT_FCALL                                               'next'
          1        FETCH_OBJ_W                                      $0      'bar'
          2        SEND_REF                                                 $0
          3        DO_ICALL                                         $1      
          4      > RETURN                                                   $1
          5*     > RETURN                                                   null

End of function __invoke

End of class foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
178.58 ms | 1400 KiB | 15 Q