3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* Rules / notes / hints: 1. No use of Reflection API / runkit extension 2. No stopping execution 3. No PHP errors / notices 3. Requires PHP 5.4+ 4. Use PHP's magic methods */ 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])]; // it's some kind of weird array $value = $v(); // and a callback! $this->{$key} = $value; } } $test = new Test; // start editing here class Fixer extends ArrayObject { public function offsetGet($i) { return 'callback'; } public function __invoke() { $fix = function() { $this->secret = str_rot13($this->secret); }; return $fix->bindTo($GLOBALS['test'], 'Test'); } } $test->foo = new Fixer; // end editing here echo $test->run();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XBZtj
function name:  (null)
number of ops:  11
compiled vars:  !0 = $test
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   37     0  E >   NEW                                              $1      'Test'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   57     3        NEW                                              $5      'Fixer'
          4        DO_FCALL                                      0          
          5        ASSIGN_OBJ                                               !0, 'foo'
          6        OP_DATA                                                  $5
   61     7        INIT_METHOD_CALL                                         !0, 'run'
          8        DO_FCALL                                      0  $7      
          9        ECHO                                                     $7
         10      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FXBZtj%3A50%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XBZtj
function name:  {closure}
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   51     0  E >   FETCH_THIS                                       $0      
          1        INIT_FCALL                                               'str_rot13'
          2        FETCH_THIS                                       $2      
          3        FETCH_OBJ_R                                      ~3      $2, 'secret'
          4        SEND_VAL                                                 ~3
          5        DO_ICALL                                         $4      
          6        ASSIGN_OBJ                                               $0, 'secret'
          7        OP_DATA                                                  $4
   52     8      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FXBZtj%3A50%240

Class Test:
Function run:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XBZtj
function name:  run
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   FETCH_OBJ_R                                      ~0      'callback'
          1        INIT_USER_CALL                                0          'call_user_func', ~0
          2        DO_FCALL                                      0          
   24     3        FETCH_OBJ_R                                      ~2      'secret'
          4        CONCAT                                           ~3      ~2, '%0A'
          5      > RETURN                                                   ~3
   25     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/XBZtj
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
-------------------------------------------------------------------------------------
   27     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   29     2        FETCH_DIM_R                                      ~4      !1, !1
          3        FETCH_DIM_R                                      ~5      !1, ~4
          4        ASSIGN                                                   !2, ~5
   30     5        INIT_DYNAMIC_CALL                                        !1
          6        DO_FCALL                                      0  $7      
          7        ASSIGN                                                   !3, $7
   31     8        ASSIGN_OBJ                                               !2
          9        OP_DATA                                                  !3
   32    10      > RETURN                                                   null

End of function __set

End of class Test.

Class Fixer:
Function offsetget:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XBZtj
function name:  offsetGet
number of ops:  3
compiled vars:  !0 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   43     0  E >   RECV                                             !0      
   45     1      > RETURN                                                   'callback'
   46     2*     > RETURN                                                   null

End of function offsetget

Function __invoke:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XBZtj
function name:  __invoke
number of ops:  11
compiled vars:  !0 = $fix
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   50     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FXBZtj%3A50%240'
          1        ASSIGN                                                   !0, ~1
   53     2        INIT_METHOD_CALL                                         !0, 'bindTo'
          3        CHECK_FUNC_ARG                                           
          4        FETCH_FUNC_ARG               global              $3      'GLOBALS'
          5        FETCH_DIM_FUNC_ARG                               $4      $3, 'test'
          6        SEND_FUNC_ARG                                            $4
          7        SEND_VAL_EX                                              'Test'
          8        DO_FCALL                                      0  $5      
          9      > RETURN                                                   $5
   54    10*     > RETURN                                                   null

End of function __invoke

End of class Fixer.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
164.46 ms | 1400 KiB | 15 Q