3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { static function a() { printf("in method: %s\nself: %s\nstatic: %s\n", __METHOD__, self::class, static::class); } } class B extends A { } $c = Closure::fromCallable('A::a'); print "getClosureScopeClass A::a:\n"; var_dump((new ReflectionFunction($c))->getClosureScopeClass()->getName()); $c(); print "\n"; $c = Closure::fromCallable('B::a'); print "getClosureScopeClass B::a:\n"; var_dump((new ReflectionFunction($c))->getClosureScopeClass()->getName()); $c();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ktqXB
function name:  (null)
number of ops:  36
compiled vars:  !0 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   INIT_STATIC_METHOD_CALL                                  'Closure', 'fromCallable'
          1        SEND_VAL                                                 'A%3A%3Aa'
          2        DO_FCALL                                      0  $1      
          3        ASSIGN                                                   !0, $1
   16     4        ECHO                                                     'getClosureScopeClass+A%3A%3Aa%3A%0A'
   17     5        INIT_FCALL                                               'var_dump'
          6        NEW                                              $3      'ReflectionFunction'
          7        SEND_VAR_EX                                              !0
          8        DO_FCALL                                      0          
          9        INIT_METHOD_CALL                                         $3, 'getClosureScopeClass'
         10        DO_FCALL                                      0  $5      
         11        INIT_METHOD_CALL                                         $5, 'getName'
         12        DO_FCALL                                      0  $6      
         13        SEND_VAR                                                 $6
         14        DO_ICALL                                                 
   18    15        INIT_DYNAMIC_CALL                                        !0
         16        DO_FCALL                                      0          
   19    17        ECHO                                                     '%0A'
   21    18        INIT_STATIC_METHOD_CALL                                  'Closure', 'fromCallable'
         19        SEND_VAL                                                 'B%3A%3Aa'
         20        DO_FCALL                                      0  $9      
         21        ASSIGN                                                   !0, $9
   22    22        ECHO                                                     'getClosureScopeClass+B%3A%3Aa%3A%0A'
   23    23        INIT_FCALL                                               'var_dump'
         24        NEW                                              $11     'ReflectionFunction'
         25        SEND_VAR_EX                                              !0
         26        DO_FCALL                                      0          
         27        INIT_METHOD_CALL                                         $11, 'getClosureScopeClass'
         28        DO_FCALL                                      0  $13     
         29        INIT_METHOD_CALL                                         $13, 'getName'
         30        DO_FCALL                                      0  $14     
         31        SEND_VAR                                                 $14
         32        DO_ICALL                                                 
   24    33        INIT_DYNAMIC_CALL                                        !0
         34        DO_FCALL                                      0          
         35      > RETURN                                                   1

Class A:
Function a:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ktqXB
function name:  a
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   INIT_FCALL                                               'printf'
          1        SEND_VAL                                                 'in+method%3A+%25s%0Aself%3A++++++%25s%0Astatic%3A++++%25s%0A'
          2        SEND_VAL                                                 'A%3A%3Aa'
          3        SEND_VAL                                                 'A'
          4        FETCH_CLASS_NAME                                 ~0      
          5        SEND_VAL                                                 ~0
          6        DO_ICALL                                                 
    8     7      > RETURN                                                   null

End of function a

End of class A.

Class B:
Function a:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ktqXB
function name:  a
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   INIT_FCALL                                               'printf'
          1        SEND_VAL                                                 'in+method%3A+%25s%0Aself%3A++++++%25s%0Astatic%3A++++%25s%0A'
          2        SEND_VAL                                                 'A%3A%3Aa'
          3        SEND_VAL                                                 'A'
          4        FETCH_CLASS_NAME                                 ~0      
          5        SEND_VAL                                                 ~0
          6        DO_ICALL                                                 
    8     7      > RETURN                                                   null

End of function a

End of class B.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.83 ms | 1011 KiB | 15 Q