3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { const FOO = 'foo'; } class Bar extends Foo { const BAR = 'bar'; } $barClassReflection = new ReflectionClass(Bar::class); $constants = $barClassReflection->getReflectionConstants(); var_dump($constants); foreach ($constants as $constant) { var_dump($constant->getName()); var_dump($constant->class); var_dump($constant->getDeclaringClass()->getName()); var_dump($constant->class === $constant->getDeclaringClass()->getName()); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 38
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 38
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 38
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 38
filename:       /in/f0WZf
function name:  (null)
number of ops:  40
compiled vars:  !0 = $barClassReflection, !1 = $constants, !2 = $constant
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   NEW                                              $3      'ReflectionClass'
          1        SEND_VAL_EX                                              'Bar'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $3
   16     4        INIT_METHOD_CALL                                         !0, 'getReflectionConstants'
          5        DO_FCALL                                      0  $6      
          6        ASSIGN                                                   !1, $6
   17     7        INIT_FCALL                                               'var_dump'
          8        SEND_VAR                                                 !1
          9        DO_ICALL                                                 
   18    10      > FE_RESET_R                                       $9      !1, ->38
         11    > > FE_FETCH_R                                               $9, !2, ->38
   19    12    >   INIT_FCALL                                               'var_dump'
         13        INIT_METHOD_CALL                                         !2, 'getName'
         14        DO_FCALL                                      0  $10     
         15        SEND_VAR                                                 $10
         16        DO_ICALL                                                 
   20    17        INIT_FCALL                                               'var_dump'
         18        FETCH_OBJ_R                                      ~12     !2, 'class'
         19        SEND_VAL                                                 ~12
         20        DO_ICALL                                                 
   21    21        INIT_FCALL                                               'var_dump'
         22        INIT_METHOD_CALL                                         !2, 'getDeclaringClass'
         23        DO_FCALL                                      0  $14     
         24        INIT_METHOD_CALL                                         $14, 'getName'
         25        DO_FCALL                                      0  $15     
         26        SEND_VAR                                                 $15
         27        DO_ICALL                                                 
   22    28        INIT_FCALL                                               'var_dump'
         29        FETCH_OBJ_R                                      ~17     !2, 'class'
         30        INIT_METHOD_CALL                                         !2, 'getDeclaringClass'
         31        DO_FCALL                                      0  $18     
         32        INIT_METHOD_CALL                                         $18, 'getName'
         33        DO_FCALL                                      0  $19     
         34        IS_IDENTICAL                                     ~20     $19, ~17
         35        SEND_VAL                                                 ~20
         36        DO_ICALL                                                 
   18    37      > JMP                                                      ->11
         38    >   FE_FREE                                                  $9
   23    39      > RETURN                                                   1

Class Foo: [no user functions]
Class Bar: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
171.33 ms | 1400 KiB | 15 Q