3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); final class A { public function __construct( public string $a = 'default', ) { } } $property = new ReflectionProperty(A::class, 'a'); var_dump($property->hasDefaultValue()); $parameter = new ReflectionParameter([A::class, '__construct'], 'a'); var_dump($parameter->isDefaultValueAvailable()); $class = new ReflectionClass(A::class); $a = $class->newInstanceWithoutConstructor(); var_dump($a->a);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/kkf24
function name:  (null)
number of ops:  32
compiled vars:  !0 = $property, !1 = $parameter, !2 = $class, !3 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   NEW                                              $4      'ReflectionProperty'
          1        SEND_VAL_EX                                              'A'
          2        SEND_VAL_EX                                              'a'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $4
   14     5        INIT_FCALL                                               'var_dump'
          6        INIT_METHOD_CALL                                         !0, 'hasDefaultValue'
          7        DO_FCALL                                      0  $7      
          8        SEND_VAR                                                 $7
          9        DO_ICALL                                                 
   16    10        NEW                                              $9      'ReflectionParameter'
         11        SEND_VAL_EX                                              <array>
         12        SEND_VAL_EX                                              'a'
         13        DO_FCALL                                      0          
         14        ASSIGN                                                   !1, $9
   17    15        INIT_FCALL                                               'var_dump'
         16        INIT_METHOD_CALL                                         !1, 'isDefaultValueAvailable'
         17        DO_FCALL                                      0  $12     
         18        SEND_VAR                                                 $12
         19        DO_ICALL                                                 
   19    20        NEW                                              $14     'ReflectionClass'
         21        SEND_VAL_EX                                              'A'
         22        DO_FCALL                                      0          
         23        ASSIGN                                                   !2, $14
   20    24        INIT_METHOD_CALL                                         !2, 'newInstanceWithoutConstructor'
         25        DO_FCALL                                      0  $17     
         26        ASSIGN                                                   !3, $17
   21    27        INIT_FCALL                                               'var_dump'
         28        FETCH_OBJ_R                                      ~19     !3, 'a'
         29        SEND_VAL                                                 ~19
         30        DO_ICALL                                                 
         31      > RETURN                                                   1

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

End of function __construct

End of class A.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
135.35 ms | 998 KiB | 14 Q