3v4l.org

run code in 300+ PHP versions simultaneously
<?php $fn = function () { return get_called_class(); }; var_dump((new ReflectionFunction($fn))->getClosureScopeClass()); class C { private static $test = 'In class C'; public static function s_fn() { $fn1 = function () { var_dump(D::$test); }; $fn2 = function () { var_dump(static::$test); }; return array($fn1, $fn2); } } class D extends C { private static $test = 'In class D'; } foreach (D::s_fn() as $f) $f();
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 13, Position 2 = 17
Branch analysis from position: 13
2 jumps found. (Code = 78) Position 1 = 14, Position 2 = 17
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
filename:       /in/vmTob
function name:  (null)
number of ops:  19
compiled vars:  !0 = $fn, !1 = $f
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FvmTob%3A2%240'
          1        ASSIGN                                                   !0, ~2
    3     2        INIT_FCALL                                               'var_dump'
          3        NEW                                              $4      'ReflectionFunction'
          4        SEND_VAR_EX                                              !0
          5        DO_FCALL                                      0          
          6        INIT_METHOD_CALL                                         $4, 'getClosureScopeClass'
          7        DO_FCALL                                      0  $6      
          8        SEND_VAR                                                 $6
          9        DO_ICALL                                                 
   19    10        INIT_STATIC_METHOD_CALL                                  'D', 's_fn'
         11        DO_FCALL                                      0  $8      
         12      > FE_RESET_R                                       $9      $8, ->17
         13    > > FE_FETCH_R                                               $9, !1, ->17
         14    >   INIT_DYNAMIC_CALL                                        !1
         15        DO_FCALL                                      0          
         16      > JMP                                                      ->13
         17    >   FE_FREE                                                  $9
         18      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FvmTob%3A2%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vmTob
function name:  {closure}
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   GET_CALLED_CLASS                                 ~0      
          1      > RETURN                                                   ~0
          2*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FvmTob%3A2%240

Function %00%7Bclosure%7D%2Fin%2FvmTob%3A9%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vmTob
function name:  {closure}
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   INIT_FCALL                                               'var_dump'
          1        FETCH_STATIC_PROP_R          global lock         ~0      'test'
          2        SEND_VAL                                                 ~0
          3        DO_ICALL                                                 
          4      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FvmTob%3A9%241

Function %00%7Bclosure%7D%2Fin%2FvmTob%3A10%242:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vmTob
function name:  {closure}
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   INIT_FCALL                                               'var_dump'
          1        FETCH_STATIC_PROP_R          global lock         ~0      'test'
          2        SEND_VAL                                                 ~0
          3        DO_ICALL                                                 
          4      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FvmTob%3A10%242

Class C:
Function s_fn:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vmTob
function name:  s_fn
number of ops:  8
compiled vars:  !0 = $fn1, !1 = $fn2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FvmTob%3A9%241'
          1        ASSIGN                                                   !0, ~2
   10     2        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FvmTob%3A10%242'
          3        ASSIGN                                                   !1, ~4
   11     4        INIT_ARRAY                                       ~6      !0
          5        ADD_ARRAY_ELEMENT                                ~6      !1
          6      > RETURN                                                   ~6
   12     7*     > RETURN                                                   null

End of function s_fn

End of class C.

Class D:
Function s_fn:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vmTob
function name:  s_fn
number of ops:  8
compiled vars:  !0 = $fn1, !1 = $fn2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FvmTob%3A9%241'
          1        ASSIGN                                                   !0, ~2
   10     2        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FvmTob%3A10%242'
          3        ASSIGN                                                   !1, ~4
   11     4        INIT_ARRAY                                       ~6      !0
          5        ADD_ARRAY_ELEMENT                                ~6      !1
          6      > RETURN                                                   ~6
   12     7*     > RETURN                                                   null

End of function s_fn

End of class D.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.06 ms | 1400 KiB | 15 Q