3v4l.org

run code in 500+ PHP versions simultaneously
<?php class Foo { public function __construct( private string $bar = 'content', ) { } } $class = new \ReflectionClass(Foo::class); $properties = $class->getProperties(); var_dump($properties[0]->getDefaultValue()); // not working $constructMethod = $class->getMethod('__construct'); $parameters = $constructMethod->getParameters(); var_dump($parameters[0]->getDefaultValue());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/o1C23
function name:  (null)
number of ops:  27
compiled vars:  !0 = $class, !1 = $properties, !2 = $constructMethod, !3 = $parameters
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   11     0  E >   NEW                                                  $4      'ReflectionClass'
          1        SEND_VAL_EX                                                  'Foo'
          2        DO_FCALL                                          0          
          3        ASSIGN                                                       !0, $4
   12     4        INIT_METHOD_CALL                                             !0, 'getProperties'
          5        DO_FCALL                                          0  $7      
          6        ASSIGN                                                       !1, $7
   13     7        INIT_FCALL                                                   'var_dump'
          8        FETCH_DIM_R                                          ~9      !1, 0
          9        INIT_METHOD_CALL                                             ~9, 'getDefaultValue'
         10        DO_FCALL                                          0  $10     
         11        SEND_VAR                                                     $10
         12        DO_ICALL                                                     
   15    13        INIT_METHOD_CALL                                             !0, 'getMethod'
         14        SEND_VAL_EX                                                  '__construct'
         15        DO_FCALL                                          0  $12     
         16        ASSIGN                                                       !2, $12
   16    17        INIT_METHOD_CALL                                             !2, 'getParameters'
         18        DO_FCALL                                          0  $14     
         19        ASSIGN                                                       !3, $14
   17    20        INIT_FCALL                                                   'var_dump'
         21        FETCH_DIM_R                                          ~16     !3, 0
         22        INIT_METHOD_CALL                                             ~16, 'getDefaultValue'
         23        DO_FCALL                                          0  $17     
         24        SEND_VAR                                                     $17
         25        DO_ICALL                                                     
         26      > RETURN                                                       1

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

End of function __construct

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
124.65 ms | 478 KiB | 8 Q