3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); function object_builder($klass, $params) { return new $klass(...$params); } class A { public function __construct(int $a){ $this->a = $a; } } var_dump(object_builder('A', [0]), object_builder('A', ['a']));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nVVpW
function name:  (null)
number of ops:  13
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'object_builder'
          2        SEND_VAL                                                 'A'
          3        SEND_VAL                                                 <array>
          4        DO_FCALL                                      0  $0      
          5        SEND_VAR                                                 $0
          6        INIT_FCALL                                               'object_builder'
          7        SEND_VAL                                                 'A'
          8        SEND_VAL                                                 <array>
          9        DO_FCALL                                      0  $1      
         10        SEND_VAR                                                 $1
         11        DO_ICALL                                                 
         12      > RETURN                                                   1

Function object_builder:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nVVpW
function name:  object_builder
number of ops:  9
compiled vars:  !0 = $klass, !1 = $params
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    6     2        FETCH_CLASS                                   0  $2      !0
          3        NEW                                              $3      $2
          4        SEND_UNPACK                                              !1
          5        CHECK_UNDEF_ARGS                                         
          6        DO_FCALL                                      1          
          7      > RETURN                                                   $3
    7     8*     > RETURN                                                   null

End of function object_builder

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

End of function __construct

End of class A.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.47 ms | 1403 KiB | 17 Q