3v4l.org

run code in 500+ PHP versions simultaneously
<?php abstract class Operation { protected static ?\ReflectionMethod $constructReflectionMethod = null; protected static ?array $abstractConstructParams = null; public function __construct( protected ?string $name = null, protected ?string $foo = null, ) {} } class Get extends Operation { private static ?array $constructParams = null; public function __construct( ?string $name = null, ?string $bar = null, protected string $method = 'GET', ) { if (null === self::$constructParams) { $rc = new \ReflectionClass($this); foreach ($rc->getMethod('__construct')->getParameters() as $v) { self::$constructParams[] = $v->getName(); } if (null === parent::$constructReflectionMethod) { parent::$constructReflectionMethod = $rc->getParentClass()->getMethod('__construct'); foreach (parent::$constructReflectionMethod->getParameters() as $v) { self::$abstractConstructParams[] = $v->getName(); } } } foreach (func_get_args() as $i => $v) { $a[self::$constructParams[$i]] = $v; } foreach (self::$abstractConstructParams as $parameter) { $args[$parameter] = $a[$parameter] ?? null; } parent::$constructReflectionMethod->invokeArgs($this, $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/l21Ei
function name:  (null)
number of ops:  9
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   51     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/l21Ei
function name:  __construct
number of ops:  7
compiled vars:  !0 = $name, !1 = $foo
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    9     0  E >   RECV_INIT                                            !0      null
   10     1        RECV_INIT                                            !1      null
    9     2        ASSIGN_OBJ                                                   'name'
          3        OP_DATA                                                      !0
   10     4        ASSIGN_OBJ                                                   'foo'
          5        OP_DATA                                                      !1
   11     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 = 43) Position 1 = 8, Position 2 = 49
Branch analysis from position: 8
2 jumps found. (Code = 77) Position 1 = 19, Position 2 = 26
Branch analysis from position: 19
2 jumps found. (Code = 78) Position 1 = 20, Position 2 = 26
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
Branch analysis from position: 26
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 49
Branch analysis from position: 30
2 jumps found. (Code = 77) Position 1 = 41, Position 2 = 48
Branch analysis from position: 41
2 jumps found. (Code = 78) Position 1 = 42, Position 2 = 48
Branch analysis from position: 42
1 jumps found. (Code = 42) Position 1 = 41
Branch analysis from position: 41
Branch analysis from position: 48
2 jumps found. (Code = 77) Position 1 = 51, Position 2 = 58
Branch analysis from position: 51
2 jumps found. (Code = 78) Position 1 = 52, Position 2 = 58
Branch analysis from position: 52
1 jumps found. (Code = 42) Position 1 = 51
Branch analysis from position: 51
Branch analysis from position: 58
2 jumps found. (Code = 77) Position 1 = 61, Position 2 = 68
Branch analysis from position: 61
2 jumps found. (Code = 78) Position 1 = 62, Position 2 = 68
Branch analysis from position: 62
1 jumps found. (Code = 42) Position 1 = 61
Branch analysis from position: 61
Branch analysis from position: 68
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 68
Branch analysis from position: 58
Branch analysis from position: 48
Branch analysis from position: 49
Branch analysis from position: 26
Branch analysis from position: 49
filename:       /in/l21Ei
function name:  __construct
number of ops:  76
compiled vars:  !0 = $name, !1 = $bar, !2 = $method, !3 = $rc, !4 = $v, !5 = $i, !6 = $a, !7 = $parameter, !8 = $args
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   19     0  E >   RECV_INIT                                            !0      null
   20     1        RECV_INIT                                            !1      null
   21     2        RECV_INIT                                            !2      'GET'
          3        ASSIGN_OBJ                                                   'method'
          4        OP_DATA                                                      !2
   23     5        FETCH_STATIC_PROP_R              unknown             ~9      'constructParams'
          6        TYPE_CHECK                                        2          ~9
          7      > JMPZ                                                         ~10, ->49
   24     8    >   NEW                                                  $11     'ReflectionClass'
          9        FETCH_THIS                                           $12     
         10        SEND_VAR_EX                                                  $12
         11        DO_FCALL                                          0          
         12        ASSIGN                                                       !3, $11
   25    13        INIT_METHOD_CALL                                             !3, 'getMethod'
         14        SEND_VAL_EX                                                  '__construct'
         15        DO_FCALL                                          0  $15     
         16        INIT_METHOD_CALL                                             $15, 'getParameters'
         17        DO_FCALL                                          0  $16     
         18      > FE_RESET_R                                           $17     $16, ->26
         19    > > FE_FETCH_R                                                   $17, !4, ->26
   26    20    >   INIT_METHOD_CALL                                             !4, 'getName'
         21        DO_FCALL                                          0  $20     
         22        FETCH_STATIC_PROP_W              unknown             $18     'constructParams'
         23        ASSIGN_DIM                                                   $18
         24        OP_DATA                                                      $20
   25    25      > JMP                                                          ->19
         26    >   FE_FREE                                                      $17
   29    27        FETCH_STATIC_PROP_R              unknown             ~21     'constructReflectionMethod'
         28        TYPE_CHECK                                        2          ~21
         29      > JMPZ                                                         ~22, ->49
   30    30    >   INIT_METHOD_CALL                                             !3, 'getParentClass'
         31        DO_FCALL                                          0  $24     
         32        INIT_METHOD_CALL                                             $24, 'getMethod'
         33        SEND_VAL_EX                                                  '__construct'
         34        DO_FCALL                                          0  $25     
         35        ASSIGN_STATIC_PROP                                           'constructReflectionMethod'
         36        OP_DATA                                                      $25
   32    37        FETCH_STATIC_PROP_R              unknown             ~26     'constructReflectionMethod'
         38        INIT_METHOD_CALL                                             ~26, 'getParameters'
         39        DO_FCALL                                          0  $27     
         40      > FE_RESET_R                                           $28     $27, ->48
         41    > > FE_FETCH_R                                                   $28, !4, ->48
   33    42    >   INIT_METHOD_CALL                                             !4, 'getName'
         43        DO_FCALL                                          0  $31     
         44        FETCH_STATIC_PROP_W              unknown             $29     'abstractConstructParams'
         45        ASSIGN_DIM                                                   $29
         46        OP_DATA                                                      $31
   32    47      > JMP                                                          ->41
         48    >   FE_FREE                                                      $28
   38    49    >   FUNC_GET_ARGS                                        ~32     
         50      > FE_RESET_R                                           $33     ~32, ->58
         51    > > FE_FETCH_R                                           ~34     $33, !4, ->58
         52    >   ASSIGN                                                       !5, ~34
   39    53        FETCH_STATIC_PROP_R              unknown             ~36     'constructParams'
         54        FETCH_DIM_R                                          ~37     ~36, !5
         55        ASSIGN_DIM                                                   !6, ~37
         56        OP_DATA                                                      !4
   38    57      > JMP                                                          ->51
         58    >   FE_FREE                                                      $33
   42    59        FETCH_STATIC_PROP_R              unknown             ~39     'abstractConstructParams'
         60      > FE_RESET_R                                           $40     ~39, ->68
         61    > > FE_FETCH_R                                                   $40, !7, ->68
   43    62    >   FETCH_DIM_IS                                         ~42     !6, !7
         63        COALESCE                                             ~43     ~42
         64        QM_ASSIGN                                            ~43     null
         65        ASSIGN_DIM                                                   !8, !7
         66        OP_DATA                                                      ~43
   42    67      > JMP                                                          ->61
         68    >   FE_FREE                                                      $40
   46    69        FETCH_STATIC_PROP_R              unknown             ~44     'constructReflectionMethod'
         70        INIT_METHOD_CALL                                             ~44, 'invokeArgs'
         71        FETCH_THIS                                           $45     
         72        SEND_VAR_EX                                                  $45
         73        SEND_VAR_EX                                                  !8
         74        DO_FCALL                                          0          
   47    75      > RETURN                                                       null

End of function __construct

End of class Get.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
128.17 ms | 486 KiB | 8 Q