3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait T { public function self(): self { return $this; } public function parent(): parent { return $this; } public function static(): static { return $this; } } $selfType = (new ReflectionMethod(T::class, 'self'))->getReturnType(); var_dump($selfType::class, $selfType->getName()); $parentType = (new ReflectionMethod(T::class, 'parent'))->getReturnType(); var_dump($parentType::class, $parentType->getName()); $staticType = (new ReflectionMethod(T::class, 'static'))->getReturnType(); var_dump($staticType::class, $staticType->getName()); final class A { use T; } $selfType = (new ReflectionMethod(A::class, 'self'))->getReturnType(); var_dump($selfType::class, $selfType->getName()); $parentType = (new ReflectionMethod(A::class, 'parent'))->getReturnType(); var_dump($parentType::class, $parentType->getName()); $staticType = (new ReflectionMethod(A::class, 'static'))->getReturnType(); var_dump($staticType::class, $staticType->getName());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/q12oj
function name:  (null)
number of ops:  86
compiled vars:  !0 = $selfType, !1 = $parentType, !2 = $staticType
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   NEW                                              $3      'ReflectionMethod'
          1        SEND_VAL_EX                                              'T'
          2        SEND_VAL_EX                                              'self'
          3        DO_FCALL                                      0          
          4        INIT_METHOD_CALL                                         $3, 'getReturnType'
          5        DO_FCALL                                      0  $5      
          6        ASSIGN                                                   !0, $5
   11     7        INIT_FCALL                                               'var_dump'
          8        FETCH_CLASS_NAME                                 ~7      !0
          9        SEND_VAL                                                 ~7
         10        INIT_METHOD_CALL                                         !0, 'getName'
         11        DO_FCALL                                      0  $8      
         12        SEND_VAR                                                 $8
         13        DO_ICALL                                                 
   13    14        NEW                                              $10     'ReflectionMethod'
         15        SEND_VAL_EX                                              'T'
         16        SEND_VAL_EX                                              'parent'
         17        DO_FCALL                                      0          
         18        INIT_METHOD_CALL                                         $10, 'getReturnType'
         19        DO_FCALL                                      0  $12     
         20        ASSIGN                                                   !1, $12
   14    21        INIT_FCALL                                               'var_dump'
         22        FETCH_CLASS_NAME                                 ~14     !1
         23        SEND_VAL                                                 ~14
         24        INIT_METHOD_CALL                                         !1, 'getName'
         25        DO_FCALL                                      0  $15     
         26        SEND_VAR                                                 $15
         27        DO_ICALL                                                 
   16    28        NEW                                              $17     'ReflectionMethod'
         29        SEND_VAL_EX                                              'T'
         30        SEND_VAL_EX                                              'static'
         31        DO_FCALL                                      0          
         32        INIT_METHOD_CALL                                         $17, 'getReturnType'
         33        DO_FCALL                                      0  $19     
         34        ASSIGN                                                   !2, $19
   17    35        INIT_FCALL                                               'var_dump'
         36        FETCH_CLASS_NAME                                 ~21     !2
         37        SEND_VAL                                                 ~21
         38        INIT_METHOD_CALL                                         !2, 'getName'
         39        DO_FCALL                                      0  $22     
         40        SEND_VAR                                                 $22
         41        DO_ICALL                                                 
   19    42        DECLARE_CLASS                                            'a'
   24    43        NEW                                              $24     'ReflectionMethod'
         44        SEND_VAL_EX                                              'A'
         45        SEND_VAL_EX                                              'self'
         46        DO_FCALL                                      0          
         47        INIT_METHOD_CALL                                         $24, 'getReturnType'
         48        DO_FCALL                                      0  $26     
         49        ASSIGN                                                   !0, $26
   25    50        INIT_FCALL                                               'var_dump'
         51        FETCH_CLASS_NAME                                 ~28     !0
         52        SEND_VAL                                                 ~28
         53        INIT_METHOD_CALL                                         !0, 'getName'
         54        DO_FCALL                                      0  $29     
         55        SEND_VAR                                                 $29
         56        DO_ICALL                                                 
   27    57        NEW                                              $31     'ReflectionMethod'
         58        SEND_VAL_EX                                              'A'
         59        SEND_VAL_EX                                              'parent'
         60        DO_FCALL                                      0          
         61        INIT_METHOD_CALL                                         $31, 'getReturnType'
         62        DO_FCALL                                      0  $33     
         63        ASSIGN                                                   !1, $33
   28    64        INIT_FCALL                                               'var_dump'
         65        FETCH_CLASS_NAME                                 ~35     !1
         66        SEND_VAL                                                 ~35
         67        INIT_METHOD_CALL                                         !1, 'getName'
         68        DO_FCALL                                      0  $36     
         69        SEND_VAR                                                 $36
         70        DO_ICALL                                                 
   30    71        NEW                                              $38     'ReflectionMethod'
         72        SEND_VAL_EX                                              'A'
         73        SEND_VAL_EX                                              'static'
         74        DO_FCALL                                      0          
         75        INIT_METHOD_CALL                                         $38, 'getReturnType'
         76        DO_FCALL                                      0  $40     
         77        ASSIGN                                                   !2, $40
   31    78        INIT_FCALL                                               'var_dump'
         79        FETCH_CLASS_NAME                                 ~42     !2
         80        SEND_VAL                                                 ~42
         81        INIT_METHOD_CALL                                         !2, 'getName'
         82        DO_FCALL                                      0  $43     
         83        SEND_VAR                                                 $43
         84        DO_ICALL                                                 
         85      > RETURN                                                   1

Class T:
Function self:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/q12oj
function name:  self
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   FETCH_THIS                                       ~0      
          1        VERIFY_RETURN_TYPE                                       ~0
          2      > RETURN                                                   ~0
          3*       VERIFY_RETURN_TYPE                                       
          4*     > RETURN                                                   null

End of function self

Function parent:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/q12oj
function name:  parent
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   FETCH_THIS                                       ~0      
          1        VERIFY_RETURN_TYPE                                       ~0
          2      > RETURN                                                   ~0
          3*       VERIFY_RETURN_TYPE                                       
          4*     > RETURN                                                   null

End of function parent

Function static:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/q12oj
function name:  static
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   FETCH_THIS                                       ~0      
          1        VERIFY_RETURN_TYPE                                       ~0
          2      > RETURN                                                   ~0
          3*       VERIFY_RETURN_TYPE                                       
          4*     > RETURN                                                   null

End of function static

End of class T.

Class A: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
163.65 ms | 962 KiB | 14 Q