3v4l.org

run code in 300+ PHP versions simultaneously
<?php var_dump(phpversion()); $some_objects = [ new SomeClass(1), new SomeClass(2), new SomeClass(3), new SomeClass(4), ]; $func = function(SomeClass $x) { $x->some_function(); return $x; }; array_walk($some_objects, $func); var_dump($some_objects); $mangled_result = array_map($func, $some_objects); var_dump($mangled_result); class SomeClass { private $number; public function __construct($number) { $this->number = $number; } public function some_function() { try { throw new Exception(); } catch (Exception $e) { MANGLE_SOMEHOW($e->getTrace()); } } } function MANGLE_SOMEHOW($trace) { foreach ($trace as $i => $frame) { if (isset($frame['args'])) { foreach ($frame['args'] as $arg_index => $arg_value) { // And here I was thinking this was a 'copy'??? $frame['args'][$arg_index] = $arg_value; } } } }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/u4PKH
function name:  (null)
number of ops:  40
compiled vars:  !0 = $some_objects, !1 = $func, !2 = $mangled_result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'phpversion'
          2        DO_ICALL                                         $3      
          3        SEND_VAR                                                 $3
          4        DO_ICALL                                                 
    4     5        NEW                                              $5      'SomeClass'
          6        SEND_VAL_EX                                              1
          7        DO_FCALL                                      0          
          8        INIT_ARRAY                                       ~7      $5
          9        NEW                                              $8      'SomeClass'
         10        SEND_VAL_EX                                              2
         11        DO_FCALL                                      0          
         12        ADD_ARRAY_ELEMENT                                ~7      $8
    5    13        NEW                                              $10     'SomeClass'
         14        SEND_VAL_EX                                              3
         15        DO_FCALL                                      0          
         16        ADD_ARRAY_ELEMENT                                ~7      $10
         17        NEW                                              $12     'SomeClass'
         18        SEND_VAL_EX                                              4
         19        DO_FCALL                                      0          
         20        ADD_ARRAY_ELEMENT                                ~7      $12
    3    21        ASSIGN                                                   !0, ~7
    7    22        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Fu4PKH%3A7%240'
         23        ASSIGN                                                   !1, ~15
   11    24        INIT_FCALL                                               'array_walk'
         25        SEND_REF                                                 !0
         26        SEND_VAR                                                 !1
         27        DO_ICALL                                                 
   12    28        INIT_FCALL                                               'var_dump'
         29        SEND_VAR                                                 !0
         30        DO_ICALL                                                 
   13    31        INIT_FCALL                                               'array_map'
         32        SEND_VAR                                                 !1
         33        SEND_VAR                                                 !0
         34        DO_ICALL                                         $19     
         35        ASSIGN                                                   !2, $19
   14    36        INIT_FCALL                                               'var_dump'
         37        SEND_VAR                                                 !2
         38        DO_ICALL                                                 
   38    39      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2Fu4PKH%3A7%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/u4PKH
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    8     1        INIT_METHOD_CALL                                         !0, 'some_function'
          2        DO_FCALL                                      0          
    9     3      > RETURN                                                   !0
   10     4*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Fu4PKH%3A7%240

Function mangle_somehow:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 16
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 16
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 15
Branch analysis from position: 6
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 14
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 14
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 14
Branch analysis from position: 15
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
filename:       /in/u4PKH
function name:  MANGLE_SOMEHOW
number of ops:  18
compiled vars:  !0 = $trace, !1 = $frame, !2 = $i, !3 = $arg_value, !4 = $arg_index
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   RECV                                             !0      
   30     1      > FE_RESET_R                                       $5      !0, ->16
          2    > > FE_FETCH_R                                       ~6      $5, !1, ->16
          3    >   ASSIGN                                                   !2, ~6
   31     4        ISSET_ISEMPTY_DIM_OBJ                         0          !1, 'args'
          5      > JMPZ                                                     ~8, ->15
   32     6    >   FETCH_DIM_R                                      ~9      !1, 'args'
          7      > FE_RESET_R                                       $10     ~9, ->14
          8    > > FE_FETCH_R                                       ~11     $10, !3, ->14
          9    >   ASSIGN                                                   !4, ~11
   34    10        FETCH_DIM_W                                      $13     !1, 'args'
         11        ASSIGN_DIM                                               $13, !4
         12        OP_DATA                                                  !3
   32    13      > JMP                                                      ->8
         14    >   FE_FREE                                                  $10
   30    15    > > JMP                                                      ->2
         16    >   FE_FREE                                                  $5
   38    17      > RETURN                                                   null

End of function mangle_somehow

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

End of function __construct

Function some_function:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 108) Position 1 = -2
Found catch point at position: 4
Branch analysis from position: 4
2 jumps found. (Code = 107) Position 1 = 5, Position 2 = -2
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/u4PKH
function name:  some_function
number of ops:  11
compiled vars:  !0 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   NEW                                              $1      'Exception'
          1        DO_FCALL                                      0          
          2      > THROW                                         0          $1
          3*       JMP                                                      ->10
   24     4  E > > CATCH                                       last         'Exception'
   25     5    >   INIT_FCALL_BY_NAME                                       'MANGLE_SOMEHOW'
          6        INIT_METHOD_CALL                                         !0, 'getTrace'
          7        DO_FCALL                                      0  $3      
          8        SEND_VAR_NO_REF_EX                                       $3
          9        DO_FCALL                                      0          
   27    10      > RETURN                                                   null

End of function some_function

End of class SomeClass.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.9 ms | 1404 KiB | 21 Q