3v4l.org

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

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

End of function %00%7Bclosure%7D%2Fin%2FhsSD6%3A9%240

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

End of function %00%7Bclosure%7D%2Fin%2FhsSD6%3A16%241

Class foo:
Function getbardumper:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hsSD6
function name:  getBarDumper
number of ops:  6
compiled vars:  !0 = $that
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   FETCH_THIS                                       ~1      
          1        ASSIGN                                                   !0, ~1
    9     2        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FhsSD6%3A9%240'
          3        BIND_LEXICAL                                             ~3, !0
          4      > RETURN                                                   ~3
   10     5*     > 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/hsSD6
function name:  getFactory
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FhsSD6%3A16%241'
          1      > RETURN                                                   ~0
   17     2*     > RETURN                                                   null

End of function getfactory

End of class foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.25 ms | 1400 KiB | 15 Q