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) { $obj = clone $this; foreach ($obj as $index => $name) { $obj->$index = array_shift($values); } 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/Fi8fQ
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
-------------------------------------------------------------------------------------
   22     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
   23     6        ASSIGN_OBJ                                               !0, 'z'
          7        OP_DATA                                                  0
   25     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
   26    14        INIT_FCALL                                               'print_r'
         15        SEND_VAR                                                 !1
         16        DO_ICALL                                                 
   27    17        INIT_DYNAMIC_CALL                                        !0
         18        SEND_VAL_EX                                              100
         19        SEND_VAL_EX                                              -100
         20        DO_FCALL                                      0  $13     
         21        ASSIGN                                                   !2, $13
   28    22        INIT_FCALL                                               'print_r'
         23        SEND_VAR                                                 !2
         24        DO_ICALL                                                 
   32    25        NEW                                              $16     'Struct'
         26        SEND_VAL_EX                                              'firstname'
         27        SEND_VAL_EX                                              'lastname'
         28        DO_FCALL                                      0          
         29        ASSIGN                                                   !3, $16
   34    30        INIT_DYNAMIC_CALL                                        !3
         31        SEND_VAL_EX                                              'William'
         32        SEND_VAL_EX                                              'Wallace'
         33        DO_FCALL                                      0  $19     
         34        ASSIGN                                                   !4, $19
   35    35        INIT_FCALL                                               'print_r'
         36        SEND_VAR                                                 !4
         37        DO_ICALL                                                 
   36    38        INIT_DYNAMIC_CALL                                        !3
         39        SEND_VAL_EX                                              'Peter'
         40        SEND_VAL_EX                                              'Griffin'
         41        DO_FCALL                                      0  $22     
         42        ASSIGN                                                   !5, $22
   37    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/Fi8fQ
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 = 5, Position 2 = 13
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 13
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
filename:       /in/Fi8fQ
function name:  __invoke
number of ops:  16
compiled vars:  !0 = $values, !1 = $obj, !2 = $name, !3 = $index
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV_VARIADIC                                    !0      
   12     1        FETCH_THIS                                       ~4      
          2        CLONE                                            ~5      ~4
          3        ASSIGN                                                   !1, ~5
   13     4      > FE_RESET_R                                       $7      !1, ->13
          5    > > FE_FETCH_R                                       ~8      $7, !2, ->13
          6    >   ASSIGN                                                   !3, ~8
   14     7        INIT_FCALL                                               'array_shift'
          8        SEND_REF                                                 !0
          9        DO_ICALL                                         $11     
         10        ASSIGN_OBJ                                               !1, !3
         11        OP_DATA                                                  $11
   13    12      > JMP                                                      ->5
         13    >   FE_FREE                                                  $7
   17    14      > RETURN                                                   !1
   18    15*     > RETURN                                                   null

End of function __invoke

End of class Struct.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
172.88 ms | 1400 KiB | 17 Q