3v4l.org

run code in 300+ PHP versions simultaneously
<?php class foo { public function bar() { return function () { return function () { }; }; } } $f = new foo(); $closure = $f->bar(); $reflection1 = new ReflectionFunction($closure); $reflection2 = new ReflectionFunction($closure()); var_dump($reflection1->getClosureScopeClass()->name); var_dump($reflection2->getClosureScopeClass()->name);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JYAPV
function name:  (null)
number of ops:  29
compiled vars:  !0 = $f, !1 = $closure, !2 = $reflection1, !3 = $reflection2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   NEW                                              $4      'foo'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $4
   17     3        INIT_METHOD_CALL                                         !0, 'bar'
          4        DO_FCALL                                      0  $7      
          5        ASSIGN                                                   !1, $7
   18     6        NEW                                              $9      'ReflectionFunction'
          7        SEND_VAR_EX                                              !1
          8        DO_FCALL                                      0          
          9        ASSIGN                                                   !2, $9
   19    10        NEW                                              $12     'ReflectionFunction'
         11        INIT_DYNAMIC_CALL                                        !1
         12        DO_FCALL                                      0  $13     
         13        SEND_VAR_NO_REF_EX                                       $13
         14        DO_FCALL                                      0          
         15        ASSIGN                                                   !3, $12
   21    16        INIT_FCALL                                               'var_dump'
         17        INIT_METHOD_CALL                                         !2, 'getClosureScopeClass'
         18        DO_FCALL                                      0  $16     
         19        FETCH_OBJ_R                                      ~17     $16, 'name'
         20        SEND_VAL                                                 ~17
         21        DO_ICALL                                                 
   22    22        INIT_FCALL                                               'var_dump'
         23        INIT_METHOD_CALL                                         !3, 'getClosureScopeClass'
         24        DO_FCALL                                      0  $19     
         25        FETCH_OBJ_R                                      ~20     $19, 'name'
         26        SEND_VAL                                                 ~20
         27        DO_ICALL                                                 
         28      > RETURN                                                   1

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

End of function %00%7Bclosure%7D%2Fin%2FJYAPV%3A7%240

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

End of function %00%7Bclosure%7D%2Fin%2FJYAPV%3A8%241

Class foo:
Function bar:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JYAPV
function name:  bar
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FJYAPV%3A7%240'
   11     1      > RETURN                                                   ~0
   12     2*     > RETURN                                                   null

End of function bar

End of class foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
193.46 ms | 1400 KiB | 15 Q