3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Bar { } class Foo extends Bar { function getSelf (self $a): self { } function getStatic (): static { } } $foo = new Foo(); $refObj = new ReflectionObject($foo); $refMethodSelf = $refObj->getMethod('getSelf'); $refMethodStatic = $refObj->getMethod('getStatic'); $refParam = $refMethodSelf->getParameters()[0]; print_r(array( 'paramType' => $refParam->getType()->getName(), 'returnTypeSelf' => $refMethodSelf->getReturnType()->getName(), 'returnTypeStatic' => $refMethodStatic->getReturnType()->getName(), ));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1nAGf
function name:  (null)
number of ops:  38
compiled vars:  !0 = $foo, !1 = $refObj, !2 = $refMethodSelf, !3 = $refMethodStatic, !4 = $refParam
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   NEW                                              $5      'Foo'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $5
   23     3        NEW                                              $8      'ReflectionObject'
          4        SEND_VAR_EX                                              !0
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !1, $8
   24     7        INIT_METHOD_CALL                                         !1, 'getMethod'
          8        SEND_VAL_EX                                              'getSelf'
          9        DO_FCALL                                      0  $11     
         10        ASSIGN                                                   !2, $11
   25    11        INIT_METHOD_CALL                                         !1, 'getMethod'
         12        SEND_VAL_EX                                              'getStatic'
         13        DO_FCALL                                      0  $13     
         14        ASSIGN                                                   !3, $13
   26    15        INIT_METHOD_CALL                                         !2, 'getParameters'
         16        DO_FCALL                                      0  $15     
         17        FETCH_DIM_R                                      ~16     $15, 0
         18        ASSIGN                                                   !4, ~16
   28    19        INIT_FCALL                                               'print_r'
   29    20        INIT_METHOD_CALL                                         !4, 'getType'
         21        DO_FCALL                                      0  $18     
         22        INIT_METHOD_CALL                                         $18, 'getName'
         23        DO_FCALL                                      0  $19     
         24        INIT_ARRAY                                       ~20     $19, 'paramType'
   30    25        INIT_METHOD_CALL                                         !2, 'getReturnType'
         26        DO_FCALL                                      0  $21     
         27        INIT_METHOD_CALL                                         $21, 'getName'
         28        DO_FCALL                                      0  $22     
         29        ADD_ARRAY_ELEMENT                                ~20     $22, 'returnTypeSelf'
   31    30        INIT_METHOD_CALL                                         !3, 'getReturnType'
         31        DO_FCALL                                      0  $23     
         32        INIT_METHOD_CALL                                         $23, 'getName'
         33        DO_FCALL                                      0  $24     
         34        ADD_ARRAY_ELEMENT                                ~20     $24, 'returnTypeStatic'
         35        SEND_VAL                                                 ~20
   28    36        DO_ICALL                                                 
   32    37      > RETURN                                                   1

Class Bar: [no user functions]
Class Foo:
Function getself:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1nAGf
function name:  getSelf
number of ops:  3
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
   14     1        VERIFY_RETURN_TYPE                                       
          2      > RETURN                                                   null

End of function getself

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

End of function getstatic

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.13 ms | 1021 KiB | 14 Q