3v4l.org

run code in 300+ PHP versions simultaneously
<?php function create(array $class) { $array = []; foreach($class as $key => $value) { if(is_array($value)) $array =+ [$key => create($value)]; else $array += [$key => $value]; } return $array; } function call(array &$class, string $member, ...$args) { if(!isset($class[$member])) exit($member.' is not a member of the class.'); else { if(!is_callable($class[$member])) return $class[$member]; else { if(!isset($args[0])) $class[$member]($class); } } } const myClass = [ 'foo' => 'Hello World', 'baz' => 3 ]; $obj = create(myClass); echo(call($obj, 'foo')); echo(call($obj, 'foo'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Lug2m
function name:  (null)
number of ops:  17
compiled vars:  !0 = $obj
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   DECLARE_CONST                                            'myClass', <array>
   25     1        INIT_FCALL                                               'create'
          2        FETCH_CONSTANT                                   ~1      'myClass'
          3        SEND_VAL                                                 ~1
          4        DO_FCALL                                      0  $2      
          5        ASSIGN                                                   !0, $2
   26     6        INIT_FCALL                                               'call'
          7        SEND_REF                                                 !0
          8        SEND_VAL                                                 'foo'
          9        DO_FCALL                                      0  $4      
         10        ECHO                                                     $4
   27    11        INIT_FCALL                                               'call'
         12        SEND_REF                                                 !0
         13        SEND_VAL                                                 'foo'
         14        DO_FCALL                                      0  $5      
         15        ECHO                                                     $5
         16      > RETURN                                                   1

Function create:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 17
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 17
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 14
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
filename:       /in/Lug2m
function name:  create
number of ops:  20
compiled vars:  !0 = $class, !1 = $array, !2 = $value, !3 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    3     1        ASSIGN                                                   !1, <array>
    4     2      > FE_RESET_R                                       $5      !0, ->17
          3    > > FE_FETCH_R                                       ~6      $5, !2, ->17
          4    >   ASSIGN                                                   !3, ~6
    5     5        TYPE_CHECK                                  128          !2
          6      > JMPZ                                                     ~8, ->14
          7    >   INIT_FCALL_BY_NAME                                       'create'
          8        SEND_VAR_EX                                              !2
          9        DO_FCALL                                      0  $9      
         10        INIT_ARRAY                                       ~10     $9, !3
         11        MUL                                              ~11     ~10, 1
         12        ASSIGN                                                   !1, ~11
         13      > JMP                                                      ->16
    6    14    >   INIT_ARRAY                                       ~13     !2, !3
         15        ASSIGN_OP                                     1          !1, ~13
    4    16    > > JMP                                                      ->3
         17    >   FE_FREE                                                  $5
    8    18      > RETURN                                                   !1
    9    19*     > RETURN                                                   null

End of function create

Function call:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 9
Branch analysis from position: 6
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 18
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 25
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
filename:       /in/Lug2m
function name:  call
number of ops:  26
compiled vars:  !0 = $class, !1 = $member, !2 = $args
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_VARIADIC                                    !2      
   11     3        ISSET_ISEMPTY_DIM_OBJ                         0  ~3      !0, !1
          4        BOOL_NOT                                         ~4      ~3
          5      > JMPZ                                                     ~4, ->9
          6    >   CONCAT                                           ~5      !1, '+is+not+a+member+of+the+class.'
          7      > EXIT                                                     ~5
          8*       JMP                                                      ->25
   13     9    >   INIT_FCALL                                               'is_callable'
         10        FETCH_DIM_R                                      ~6      !0, !1
         11        SEND_VAL                                                 ~6
         12        DO_ICALL                                         $7      
         13        BOOL_NOT                                         ~8      $7
         14      > JMPZ                                                     ~8, ->18
         15    >   FETCH_DIM_R                                      ~9      !0, !1
         16      > RETURN                                                   ~9
         17*       JMP                                                      ->25
   15    18    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~10     !2, 0
         19        BOOL_NOT                                         ~11     ~10
         20      > JMPZ                                                     ~11, ->25
         21    >   FETCH_DIM_R                                      ~12     !0, !1
         22        INIT_DYNAMIC_CALL                                        ~12
         23        SEND_VAR_EX                                              !0
         24        DO_FCALL                                      0          
   18    25    > > RETURN                                                   null

End of function call

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.67 ms | 1394 KiB | 18 Q