3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Struct { function __construct() { foreach (func_get_args() as $name) { $this->$name = null; } } function __invoke() { $values = func_get_args(); $obj = clone $this; foreach (array_keys(get_object_vars($this)) as $index => $name) { if ( isset($values[$index]) ) { $obj->$name = $values[$index]; } } return $obj; } } $Coord = new Struct('x', 'y', 'z'); $Coord->z = 0; $c1 = $Coord(12, 45, -34); print_r($c1); $c2 = $Coord(100, -100); print_r($c2); $Person = new Struct('firstname', 'lastname'); $p1 = $Person('William', 'Wallace'); print_r($p1); $p2 = $Person('Peter', 'Griffin'); print_r($p2);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/iVGGM
function name:  (null)
number of ops:  47
compiled vars:  !0 = $Coord, !1 = $c1, !2 = $c2, !3 = $Person, !4 = $p1, !5 = $p2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   NEW                                              $6      'Struct'
          1        SEND_VAL_EX                                              'x'
          2        SEND_VAL_EX                                              'y'
          3        SEND_VAL_EX                                              'z'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !0, $6
   27     6        ASSIGN_OBJ                                               !0, 'z'
          7        OP_DATA                                                  0
   29     8        INIT_DYNAMIC_CALL                                        !0
          9        SEND_VAL_EX                                              12
         10        SEND_VAL_EX                                              45
         11        SEND_VAL_EX                                              -34
         12        DO_FCALL                                      0  $10     
         13        ASSIGN                                                   !1, $10
   30    14        INIT_FCALL                                               'print_r'
         15        SEND_VAR                                                 !1
         16        DO_ICALL                                                 
   31    17        INIT_DYNAMIC_CALL                                        !0
         18        SEND_VAL_EX                                              100
         19        SEND_VAL_EX                                              -100
         20        DO_FCALL                                      0  $13     
         21        ASSIGN                                                   !2, $13
   32    22        INIT_FCALL                                               'print_r'
         23        SEND_VAR                                                 !2
         24        DO_ICALL                                                 
   36    25        NEW                                              $16     'Struct'
         26        SEND_VAL_EX                                              'firstname'
         27        SEND_VAL_EX                                              'lastname'
         28        DO_FCALL                                      0          
         29        ASSIGN                                                   !3, $16
   38    30        INIT_DYNAMIC_CALL                                        !3
         31        SEND_VAL_EX                                              'William'
         32        SEND_VAL_EX                                              'Wallace'
         33        DO_FCALL                                      0  $19     
         34        ASSIGN                                                   !4, $19
   39    35        INIT_FCALL                                               'print_r'
         36        SEND_VAR                                                 !4
         37        DO_ICALL                                                 
   40    38        INIT_DYNAMIC_CALL                                        !3
         39        SEND_VAL_EX                                              'Peter'
         40        SEND_VAL_EX                                              'Griffin'
         41        DO_FCALL                                      0  $22     
         42        ASSIGN                                                   !5, $22
   41    43        INIT_FCALL                                               'print_r'
         44        SEND_VAR                                                 !5
         45        DO_ICALL                                                 
         46      > RETURN                                                   1

Class Struct:
Function __construct:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 6
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 6
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
filename:       /in/iVGGM
function name:  __construct
number of ops:  8
compiled vars:  !0 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   FUNC_GET_ARGS                                    ~1      
          1      > FE_RESET_R                                       $2      ~1, ->6
          2    > > FE_FETCH_R                                               $2, !0, ->6
    7     3    >   ASSIGN_OBJ                                               !0
          4        OP_DATA                                                  null
    6     5      > JMP                                                      ->2
          6    >   FE_FREE                                                  $2
    9     7      > RETURN                                                   null

End of function __construct

Function __invoke:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 13, Position 2 = 21
Branch analysis from position: 13
2 jumps found. (Code = 78) Position 1 = 14, Position 2 = 21
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 20
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 20
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
filename:       /in/iVGGM
function name:  __invoke
number of ops:  24
compiled vars:  !0 = $values, !1 = $obj, !2 = $name, !3 = $index
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   FUNC_GET_ARGS                                    ~4      
          1        ASSIGN                                                   !0, ~4
   14     2        FETCH_THIS                                       ~6      
          3        CLONE                                            ~7      ~6
          4        ASSIGN                                                   !1, ~7
   15     5        INIT_FCALL                                               'array_keys'
          6        INIT_FCALL                                               'get_object_vars'
          7        FETCH_THIS                                       ~9      
          8        SEND_VAL                                                 ~9
          9        DO_ICALL                                         $10     
         10        SEND_VAR                                                 $10
         11        DO_ICALL                                         $11     
         12      > FE_RESET_R                                       $12     $11, ->21
         13    > > FE_FETCH_R                                       ~13     $12, !2, ->21
         14    >   ASSIGN                                                   !3, ~13
   16    15        ISSET_ISEMPTY_DIM_OBJ                         0          !0, !3
         16      > JMPZ                                                     ~15, ->20
   17    17    >   FETCH_DIM_R                                      ~17     !0, !3
         18        ASSIGN_OBJ                                               !1, !2
         19        OP_DATA                                                  ~17
   15    20    > > JMP                                                      ->13
         21    >   FE_FREE                                                  $12
   21    22      > RETURN                                                   !1
   22    23*     > RETURN                                                   null

End of function __invoke

End of class Struct.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.83 ms | 1404 KiB | 19 Q