3v4l.org

run code in 500+ PHP versions simultaneously
<?php abstract class Operation { public function __construct( protected ?string $name = null, protected ?string $foo = null, ) {} } class Get extends Operation { public function __construct( ?string $name = null, ?string $bar = null, protected string $method = 'GET', ) { $params = (new ReflectionClass(self::class))->getMethod('__construct')->getParameters(); $a = []; foreach (func_get_args() as $i => $v) { $a[$params[$i]->getName()] = $v; } $args = []; foreach ((new ReflectionClass(parent::class))->getMethod('__construct')->getParameters() as $parameter) { $args[$name = $parameter->getName()] = $a[$name] ?? null; } call_user_func_array('parent::__construct', $args); } } var_dump(new Get(name: 'test', method: 'GET'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/OFhko
function name:  (null)
number of ops:  9
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   37     0  E >   INIT_FCALL                                                   'var_dump'
          1        NEW                                                  $0      'Get'
          2        SEND_VAL_EX                                                  'test', 'name'
          3        SEND_VAL_EX                                                  'GET', 'method'
          4        CHECK_UNDEF_ARGS                                             
          5        DO_FCALL                                          1          
          6        SEND_VAR                                                     $0
          7        DO_ICALL                                                     
          8      > RETURN                                                       1

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

End of function __construct

End of class Operation.

Class Get:
Function __construct:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 17, Position 2 = 25
Branch analysis from position: 17
2 jumps found. (Code = 78) Position 1 = 18, Position 2 = 25
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
Branch analysis from position: 25
2 jumps found. (Code = 77) Position 1 = 36, Position 2 = 46
Branch analysis from position: 36
2 jumps found. (Code = 78) Position 1 = 37, Position 2 = 46
Branch analysis from position: 37
1 jumps found. (Code = 42) Position 1 = 36
Branch analysis from position: 36
Branch analysis from position: 46
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 46
Branch analysis from position: 25
filename:       /in/OFhko
function name:  __construct
number of ops:  52
compiled vars:  !0 = $name, !1 = $bar, !2 = $method, !3 = $params, !4 = $a, !5 = $v, !6 = $i, !7 = $args, !8 = $parameter
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   14     0  E >   RECV_INIT                                            !0      null
   15     1        RECV_INIT                                            !1      null
   16     2        RECV_INIT                                            !2      'GET'
          3        ASSIGN_OBJ                                                   'method'
          4        OP_DATA                                                      !2
   19     5        NEW                                                  $9      'ReflectionClass'
          6        SEND_VAL_EX                                                  'Get'
          7        DO_FCALL                                          0          
          8        INIT_METHOD_CALL                                             $9, 'getMethod'
          9        SEND_VAL_EX                                                  '__construct'
         10        DO_FCALL                                          0  $11     
         11        INIT_METHOD_CALL                                             $11, 'getParameters'
         12        DO_FCALL                                          0  $12     
         13        ASSIGN                                                       !3, $12
   20    14        ASSIGN                                                       !4, <array>
   22    15        FUNC_GET_ARGS                                        ~15     
         16      > FE_RESET_R                                           $16     ~15, ->25
         17    > > FE_FETCH_R                                           ~17     $16, !5, ->25
         18    >   ASSIGN                                                       !6, ~17
   23    19        FETCH_DIM_R                                          ~19     !3, !6
         20        INIT_METHOD_CALL                                             ~19, 'getName'
         21        DO_FCALL                                          0  $20     
         22        ASSIGN_DIM                                                   !4, $20
         23        OP_DATA                                                      !5
   22    24      > JMP                                                          ->17
         25    >   FE_FREE                                                      $16
   26    26        ASSIGN                                                       !7, <array>
   28    27        NEW                                                  $23     'ReflectionClass'
         28        SEND_VAL_EX                                                  'Operation'
         29        DO_FCALL                                          0          
         30        INIT_METHOD_CALL                                             $23, 'getMethod'
         31        SEND_VAL_EX                                                  '__construct'
         32        DO_FCALL                                          0  $25     
         33        INIT_METHOD_CALL                                             $25, 'getParameters'
         34        DO_FCALL                                          0  $26     
         35      > FE_RESET_R                                           $27     $26, ->46
         36    > > FE_FETCH_R                                                   $27, !8, ->46
   29    37    >   INIT_METHOD_CALL                                             !8, 'getName'
         38        DO_FCALL                                          0  $28     
         39        ASSIGN                                               ~29     !0, $28
         40        FETCH_DIM_IS                                         ~31     !4, !0
         41        COALESCE                                             ~32     ~31
         42        QM_ASSIGN                                            ~32     null
         43        ASSIGN_DIM                                                   !7, ~29
         44        OP_DATA                                                      ~32
   28    45      > JMP                                                          ->36
         46    >   FE_FREE                                                      $27
   32    47        INIT_USER_CALL                                    0          'call_user_func_array', 'parent%3A%3A__construct'
         48        SEND_ARRAY                                                   !7
         49        CHECK_UNDEF_ARGS                                             
         50        DO_FCALL                                          1          
   33    51      > RETURN                                                       null

End of function __construct

End of class Get.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
129.85 ms | 482 KiB | 8 Q