3v4l.org

run code in 300+ PHP versions simultaneously
<?php class foo { protected $bar = 'A bar'; public function getBarDumper() { return function() { var_dump($this->bar); }; } public static function getFactory() { // la fonction anonyme suivante est statique // car elle est déclarée dans une méthode statique. return function() { return new static(); }; } } $factory = foo::getFactory(); $reflectedFactory = new \reflectionFunction($factory); var_dump($reflectedFactory->getClosureScopeClass(), '--');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/QSVeM
function name:  (null)
number of ops:  14
compiled vars:  !0 = $factory, !1 = $reflectedFactory
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   INIT_STATIC_METHOD_CALL                                  'foo', 'getFactory'
          1        DO_FCALL                                      0  $2      
          2        ASSIGN                                                   !0, $2
   20     3        NEW                                              $4      'reflectionFunction'
          4        SEND_VAR_EX                                              !0
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !1, $4
   21     7        INIT_FCALL                                               'var_dump'
          8        INIT_METHOD_CALL                                         !1, 'getClosureScopeClass'
          9        DO_FCALL                                      0  $7      
         10        SEND_VAR                                                 $7
         11        SEND_VAL                                                 '--'
         12        DO_ICALL                                                 
         13      > RETURN                                                   1

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

End of function %00%7Bclosure%7D%2Fin%2FQSVeM%3A8%240

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

End of function %00%7Bclosure%7D%2Fin%2FQSVeM%3A15%241

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

End of function getbardumper

Function getfactory:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/QSVeM
function name:  getFactory
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FQSVeM%3A15%241'
          1      > RETURN                                                   ~0
   16     2*     > RETURN                                                   null

End of function getfactory

End of class foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.8 ms | 1400 KiB | 15 Q