3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { public function getClosure() { var_dump(self::class, static::class); return function () { }; } } class B extends A { } $b = new B(); $c = $b->getClosure(); $r = new ReflectionFunction($c); var_dump($r->getClosureThis() === $b); var_dump($r->getClosureScopeClass()); // self::class var_dump($r->getClosureCalledClass()); // static::class
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JOphS
function name:  (null)
number of ops:  27
compiled vars:  !0 = $b, !1 = $c, !2 = $r
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   NEW                                              $3      'B'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $3
   17     3        INIT_METHOD_CALL                                         !0, 'getClosure'
          4        DO_FCALL                                      0  $6      
          5        ASSIGN                                                   !1, $6
   18     6        NEW                                              $8      'ReflectionFunction'
          7        SEND_VAR_EX                                              !1
          8        DO_FCALL                                      0          
          9        ASSIGN                                                   !2, $8
   19    10        INIT_FCALL                                               'var_dump'
         11        INIT_METHOD_CALL                                         !2, 'getClosureThis'
         12        DO_FCALL                                      0  $11     
         13        IS_IDENTICAL                                     ~12     !0, $11
         14        SEND_VAL                                                 ~12
         15        DO_ICALL                                                 
   20    16        INIT_FCALL                                               'var_dump'
         17        INIT_METHOD_CALL                                         !2, 'getClosureScopeClass'
         18        DO_FCALL                                      0  $14     
         19        SEND_VAR                                                 $14
         20        DO_ICALL                                                 
   21    21        INIT_FCALL                                               'var_dump'
         22        INIT_METHOD_CALL                                         !2, 'getClosureCalledClass'
         23        DO_FCALL                                      0  $16     
         24        SEND_VAR                                                 $16
         25        DO_ICALL                                                 
         26      > RETURN                                                   1

Class A:
Function getclosure:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JOphS
function name:  getClosure
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   INIT_FCALL                                               'var_dump'
          1        SEND_VAL                                                 'A'
          2        FETCH_CLASS_NAME                                 ~0      
          3        SEND_VAL                                                 ~0
          4        DO_ICALL                                                 
    6     5        DECLARE_LAMBDA_FUNCTION                          ~2      [0]
    8     6      > RETURN                                                   ~2
    9     7*     > RETURN                                                   null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JOphS
function name:  {closure}
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E > > RETURN                                                   null

End of Dynamic Function 0

End of function getclosure

End of class A.

Class B:
Function getclosure:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JOphS
function name:  getClosure
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   INIT_FCALL                                               'var_dump'
          1        SEND_VAL                                                 'A'
          2        FETCH_CLASS_NAME                                 ~0      
          3        SEND_VAL                                                 ~0
          4        DO_ICALL                                                 
    6     5        DECLARE_LAMBDA_FUNCTION                          ~2      [0]
    8     6      > RETURN                                                   ~2
    9     7*     > RETURN                                                   null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JOphS
function name:  {closure}
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E > > RETURN                                                   null

End of Dynamic Function 0

End of function getclosure

End of class B.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
136.74 ms | 1002 KiB | 14 Q