3v4l.org

run code in 500+ PHP versions simultaneously
<?php declare(strict_types = 1); trait Help { public function attachTag( string $type = self::class ): void { var_dump($type); } } $ref = new \ReflectionClass(Help::class); $parameters = $ref->getMethod('attachTag')->getParameters(); foreach ($parameters as $p) { var_dump($p->getName()); var_dump($p->getDefaultValue()); } class HelloWorld { use Help; public function sayHello(DateTimeImutable $date): void { $this->attachTag(); } } var_dump('-------'); $ref = new \ReflectionClass(HelloWorld::class); $parameters = $ref->getMethod('attachTag')->getParameters(); foreach ($parameters as $p) { var_dump($p->getName()); var_dump($p->getDefaultValue()); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 23
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 23
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 23
2 jumps found. (Code = 77) Position 1 = 39, Position 2 = 51
Branch analysis from position: 39
2 jumps found. (Code = 78) Position 1 = 40, Position 2 = 51
Branch analysis from position: 40
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
Branch analysis from position: 51
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 51
Branch analysis from position: 23
filename:       /in/iopRK
function name:  (null)
number of ops:  53
compiled vars:  !0 = $ref, !1 = $parameters, !2 = $p
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   12     0  E >   NEW                                                  $3      'ReflectionClass'
          1        SEND_VAL_EX                                                  'Help'
          2        DO_FCALL                                          0          
          3        ASSIGN                                                       !0, $3
   13     4        INIT_METHOD_CALL                                             !0, 'getMethod'
          5        SEND_VAL_EX                                                  'attachTag'
          6        DO_FCALL                                          0  $6      
          7        INIT_METHOD_CALL                                             $6, 'getParameters'
          8        DO_FCALL                                          0  $7      
          9        ASSIGN                                                       !1, $7
   14    10      > FE_RESET_R                                           $9      !1, ->23
         11    > > FE_FETCH_R                                                   $9, !2, ->23
   15    12    >   INIT_FCALL                                                   'var_dump'
         13        INIT_METHOD_CALL                                             !2, 'getName'
         14        DO_FCALL                                          0  $10     
         15        SEND_VAR                                                     $10
         16        DO_ICALL                                                     
   16    17        INIT_FCALL                                                   'var_dump'
         18        INIT_METHOD_CALL                                             !2, 'getDefaultValue'
         19        DO_FCALL                                          0  $12     
         20        SEND_VAR                                                     $12
         21        DO_ICALL                                                     
   14    22      > JMP                                                          ->11
         23    >   FE_FREE                                                      $9
   19    24        DECLARE_CLASS                                                'helloworld'
   29    25        INIT_FCALL                                                   'var_dump'
         26        SEND_VAL                                                     '-------'
         27        DO_ICALL                                                     
   31    28        NEW                                                  $15     'ReflectionClass'
         29        SEND_VAL_EX                                                  'HelloWorld'
         30        DO_FCALL                                          0          
         31        ASSIGN                                                       !0, $15
   32    32        INIT_METHOD_CALL                                             !0, 'getMethod'
         33        SEND_VAL_EX                                                  'attachTag'
         34        DO_FCALL                                          0  $18     
         35        INIT_METHOD_CALL                                             $18, 'getParameters'
         36        DO_FCALL                                          0  $19     
         37        ASSIGN                                                       !1, $19
   33    38      > FE_RESET_R                                           $21     !1, ->51
         39    > > FE_FETCH_R                                                   $21, !2, ->51
   34    40    >   INIT_FCALL                                                   'var_dump'
         41        INIT_METHOD_CALL                                             !2, 'getName'
         42        DO_FCALL                                          0  $22     
         43        SEND_VAR                                                     $22
         44        DO_ICALL                                                     
   35    45        INIT_FCALL                                                   'var_dump'
         46        INIT_METHOD_CALL                                             !2, 'getDefaultValue'
         47        DO_FCALL                                          0  $24     
         48        SEND_VAR                                                     $24
         49        DO_ICALL                                                     
   33    50      > JMP                                                          ->39
         51    >   FE_FREE                                                      $21
   36    52      > RETURN                                                       1

Class Help:
Function attachtag:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/iopRK
function name:  attachTag
number of ops:  5
compiled vars:  !0 = $type
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    6     0  E >   RECV_INIT                                            !0      <const ast>
    8     1        INIT_FCALL                                                   'var_dump'
          2        SEND_VAR                                                     !0
          3        DO_ICALL                                                     
    9     4      > RETURN                                                       null

End of function attachtag

End of class Help.

Class HelloWorld:
Function sayhello:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/iopRK
function name:  sayHello
number of ops:  4
compiled vars:  !0 = $date
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   23     0  E >   RECV                                                 !0      
   25     1        INIT_METHOD_CALL                                             'attachTag'
          2        DO_FCALL                                          0          
   26     3      > RETURN                                                       null

End of function sayhello

End of class HelloWorld.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
168.8 ms | 2126 KiB | 14 Q