3v4l.org

run code in 300+ PHP versions simultaneously
<?php const A = 'waa'; class A {} class B { public function __construct(A $a = null) { } public function test($a = A) { } } $r = new ReflectionMethod('B', 'test'); $p = $r->getParameters()[0]; var_dump($p->getName(), $p->allowsNull(), $p->getDefaultValue()); $r = new ReflectionMethod('B', '__construct'); $p = $r->getParameters()[0]; var_dump($p->getName(), $p->isDefaultValueConstant(), $p->allowsNull(), $p->getDefaultValue());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KULp0
function name:  (null)
number of ops:  45
compiled vars:  !0 = $r, !1 = $p
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CONST                                            'A', 'waa'
   16     1        NEW                                              $2      'ReflectionMethod'
          2        SEND_VAL_EX                                              'B'
          3        SEND_VAL_EX                                              'test'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !0, $2
   17     6        INIT_METHOD_CALL                                         !0, 'getParameters'
          7        DO_FCALL                                      0  $5      
          8        FETCH_DIM_R                                      ~6      $5, 0
          9        ASSIGN                                                   !1, ~6
   18    10        INIT_FCALL                                               'var_dump'
         11        INIT_METHOD_CALL                                         !1, 'getName'
         12        DO_FCALL                                      0  $8      
         13        SEND_VAR                                                 $8
         14        INIT_METHOD_CALL                                         !1, 'allowsNull'
         15        DO_FCALL                                      0  $9      
         16        SEND_VAR                                                 $9
         17        INIT_METHOD_CALL                                         !1, 'getDefaultValue'
         18        DO_FCALL                                      0  $10     
         19        SEND_VAR                                                 $10
         20        DO_ICALL                                                 
   20    21        NEW                                              $12     'ReflectionMethod'
         22        SEND_VAL_EX                                              'B'
         23        SEND_VAL_EX                                              '__construct'
         24        DO_FCALL                                      0          
         25        ASSIGN                                                   !0, $12
   21    26        INIT_METHOD_CALL                                         !0, 'getParameters'
         27        DO_FCALL                                      0  $15     
         28        FETCH_DIM_R                                      ~16     $15, 0
         29        ASSIGN                                                   !1, ~16
   22    30        INIT_FCALL                                               'var_dump'
         31        INIT_METHOD_CALL                                         !1, 'getName'
         32        DO_FCALL                                      0  $18     
         33        SEND_VAR                                                 $18
         34        INIT_METHOD_CALL                                         !1, 'isDefaultValueConstant'
         35        DO_FCALL                                      0  $19     
         36        SEND_VAR                                                 $19
         37        INIT_METHOD_CALL                                         !1, 'allowsNull'
         38        DO_FCALL                                      0  $20     
         39        SEND_VAR                                                 $20
         40        INIT_METHOD_CALL                                         !1, 'getDefaultValue'
         41        DO_FCALL                                      0  $21     
         42        SEND_VAR                                                 $21
         43        DO_ICALL                                                 
         44      > RETURN                                                   1

Class A: [no user functions]
Class B:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KULp0
function name:  __construct
number of ops:  2
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV_INIT                                        !0      null
    9     1      > RETURN                                                   null

End of function __construct

Function test:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KULp0
function name:  test
number of ops:  2
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV_INIT                                        !0      <const ast>
   13     1      > RETURN                                                   null

End of function test

End of class B.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.5 ms | 1392 KiB | 15 Q