3v4l.org

run code in 300+ PHP versions simultaneously
<?php abstract class A { const __default = null; public function __construct() { $class = get_class($this); $r = new ReflectionClass($class); $constants = $r->getConstants(); var_dump($constants); } } class B extends A { const __default = self::A; const A = 'a'; const B = 'b'; } class C extends B { const __default = self::C; const A = 'A'; const C = 'c'; } $enum = new C();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HjJtg
function name:  (null)
number of ops:  4
compiled vars:  !0 = $enum
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   NEW                                              $1      'C'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
          3      > RETURN                                                   1

Class A:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HjJtg
function name:  __construct
number of ops:  14
compiled vars:  !0 = $class, !1 = $r, !2 = $constants
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   FETCH_THIS                                       ~3      
          1        GET_CLASS                                        ~4      ~3
          2        ASSIGN                                                   !0, ~4
   11     3        NEW                                              $6      'ReflectionClass'
          4        SEND_VAR_EX                                              !0
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !1, $6
   12     7        INIT_METHOD_CALL                                         !1, 'getConstants'
          8        DO_FCALL                                      0  $9      
          9        ASSIGN                                                   !2, $9
   13    10        INIT_FCALL                                               'var_dump'
         11        SEND_VAR                                                 !2
         12        DO_ICALL                                                 
   14    13      > RETURN                                                   null

End of function __construct

End of class A.

Class B:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HjJtg
function name:  __construct
number of ops:  14
compiled vars:  !0 = $class, !1 = $r, !2 = $constants
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   FETCH_THIS                                       ~3      
          1        GET_CLASS                                        ~4      ~3
          2        ASSIGN                                                   !0, ~4
   11     3        NEW                                              $6      'ReflectionClass'
          4        SEND_VAR_EX                                              !0
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !1, $6
   12     7        INIT_METHOD_CALL                                         !1, 'getConstants'
          8        DO_FCALL                                      0  $9      
          9        ASSIGN                                                   !2, $9
   13    10        INIT_FCALL                                               'var_dump'
         11        SEND_VAR                                                 !2
         12        DO_ICALL                                                 
   14    13      > RETURN                                                   null

End of function __construct

End of class B.

Class C:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HjJtg
function name:  __construct
number of ops:  14
compiled vars:  !0 = $class, !1 = $r, !2 = $constants
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   FETCH_THIS                                       ~3      
          1        GET_CLASS                                        ~4      ~3
          2        ASSIGN                                                   !0, ~4
   11     3        NEW                                              $6      'ReflectionClass'
          4        SEND_VAR_EX                                              !0
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !1, $6
   12     7        INIT_METHOD_CALL                                         !1, 'getConstants'
          8        DO_FCALL                                      0  $9      
          9        ASSIGN                                                   !2, $9
   13    10        INIT_FCALL                                               'var_dump'
         11        SEND_VAR                                                 !2
         12        DO_ICALL                                                 
   14    13      > RETURN                                                   null

End of function __construct

End of class C.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
172.37 ms | 1400 KiB | 15 Q