3v4l.org

run code in 500+ PHP versions simultaneously
<?php declare(strict_types=1); class Foo { public function __construct( public bool $bool, public int $int, ) {} } $args = ['bar', '10']; $reflection = new \ReflectionClass(Foo::class); $constructor = $reflection->getConstructor(); $instance = $reflection->newInstance(...$args); var_dump($instance); // Expected new Foo(...$args);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KtY24
function name:  (null)
number of ops:  22
compiled vars:  !0 = $args, !1 = $reflection, !2 = $constructor, !3 = $instance
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   11     0  E >   ASSIGN                                                       !0, <array>
   13     1        NEW                                                  $5      'ReflectionClass'
          2        SEND_VAL_EX                                                  'Foo'
          3        DO_FCALL                                          0          
          4        ASSIGN                                                       !1, $5
   14     5        INIT_METHOD_CALL                                             !1, 'getConstructor'
          6        DO_FCALL                                          0  $8      
          7        ASSIGN                                                       !2, $8
   15     8        INIT_METHOD_CALL                                             !1, 'newInstance'
          9        SEND_UNPACK                                                  !0
         10        CHECK_UNDEF_ARGS                                             
         11        DO_FCALL                                          1  $10     
         12        ASSIGN                                                       !3, $10
   17    13        INIT_FCALL                                                   'var_dump'
         14        SEND_VAR                                                     !3
         15        DO_ICALL                                                     
   21    16        NEW                                                  $13     'Foo'
         17        SEND_UNPACK                                                  !0
         18        CHECK_UNDEF_ARGS                                             
         19        DO_FCALL                                          1          
         20        FREE                                                         $13
         21      > RETURN                                                       1

Class Foo:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KtY24
function name:  __construct
number of ops:  7
compiled vars:  !0 = $bool, !1 = $int
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    7     0  E >   RECV                                                 !0      
    8     1        RECV                                                 !1      
    7     2        ASSIGN_OBJ                                                   'bool'
          3        OP_DATA                                                      !0
    8     4        ASSIGN_OBJ                                                   'int'
          5        OP_DATA                                                      !1
    9     6      > RETURN                                                       null

End of function __construct

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
120.48 ms | 478 KiB | 8 Q