3v4l.org

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

Function %00%7Bclosure%7D%2Fin%2F0oeqe%3A8%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0oeqe
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 function %00%7Bclosure%7D%2Fin%2F0oeqe%3A8%240

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

End of function %00%7Bclosure%7D%2Fin%2F0oeqe%3A11%241

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

End of function bar

Function getstaticclosure:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0oeqe
function name:  getStaticClosure
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%2F0oeqe%3A8%240'
          1      > RETURN                                                   ~0
    9     2*     > RETURN                                                   null

End of function getstaticclosure

Function getclosure:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0oeqe
function name:  getClosure
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F0oeqe%3A11%241'
   13     1      > RETURN                                                   ~0
   14     2*     > RETURN                                                   null

End of function getclosure

End of class foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.79 ms | 1400 KiB | 15 Q