3v4l.org

run code in 300+ PHP versions simultaneously
<?php // investigating closures in closures $f = function() { static $p = 'p'; return static function() { return static::$p; }; }; $g = static function() { static $p = 'p'; return static function() { return static::$p; }; }; $h = function() { static $p = 'p'; return function() { return static::$p; }; }; $f_inner = $f(); $g_inner = $g(); $h_inner = $h(); var_dump($f_inner(), $g_inner(), $h_nner());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GqjpZ
function name:  (null)
number of ops:  27
compiled vars:  !0 = $f, !1 = $g, !2 = $h, !3 = $f_inner, !4 = $g_inner, !5 = $h_inner, !6 = $h_nner
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FGqjpZ%3A3%240'
          1        ASSIGN                                                   !0, ~7
   11     2        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FGqjpZ%3A11%242'
          3        ASSIGN                                                   !1, ~9
   19     4        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FGqjpZ%3A19%244'
          5        ASSIGN                                                   !2, ~11
   26     6        INIT_DYNAMIC_CALL                                        !0
          7        DO_FCALL                                      0  $13     
          8        ASSIGN                                                   !3, $13
   27     9        INIT_DYNAMIC_CALL                                        !1
         10        DO_FCALL                                      0  $15     
         11        ASSIGN                                                   !4, $15
   28    12        INIT_DYNAMIC_CALL                                        !2
         13        DO_FCALL                                      0  $17     
         14        ASSIGN                                                   !5, $17
   29    15        INIT_FCALL                                               'var_dump'
         16        INIT_DYNAMIC_CALL                                        !3
         17        DO_FCALL                                      0  $19     
         18        SEND_VAR                                                 $19
         19        INIT_DYNAMIC_CALL                                        !4
         20        DO_FCALL                                      0  $20     
         21        SEND_VAR                                                 $20
         22        INIT_DYNAMIC_CALL                                        !6
         23        DO_FCALL                                      0  $21     
         24        SEND_VAR                                                 $21
         25        DO_ICALL                                                 
         26      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FGqjpZ%3A3%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GqjpZ
function name:  {closure}
number of ops:  4
compiled vars:  !0 = $p
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   BIND_STATIC                                              !0
    5     1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FGqjpZ%3A5%241'
    7     2      > RETURN                                                   ~1
    8     3*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FGqjpZ%3A3%240

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

End of function %00%7Bclosure%7D%2Fin%2FGqjpZ%3A5%241

Function %00%7Bclosure%7D%2Fin%2FGqjpZ%3A11%242:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GqjpZ
function name:  {closure}
number of ops:  4
compiled vars:  !0 = $p
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   BIND_STATIC                                              !0
   13     1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FGqjpZ%3A13%243'
   15     2      > RETURN                                                   ~1
   16     3*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FGqjpZ%3A11%242

Function %00%7Bclosure%7D%2Fin%2FGqjpZ%3A13%243:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GqjpZ
function name:  {closure}
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   FETCH_STATIC_PROP_R          unknown             ~0      'p'
          1      > RETURN                                                   ~0
   15     2*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FGqjpZ%3A13%243

Function %00%7Bclosure%7D%2Fin%2FGqjpZ%3A19%244:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GqjpZ
function name:  {closure}
number of ops:  4
compiled vars:  !0 = $p
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   BIND_STATIC                                              !0
   21     1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FGqjpZ%3A21%245'
   23     2      > RETURN                                                   ~1
   24     3*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FGqjpZ%3A19%244

Function %00%7Bclosure%7D%2Fin%2FGqjpZ%3A21%245:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GqjpZ
function name:  {closure}
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   FETCH_STATIC_PROP_R          unknown             ~0      'p'
          1      > RETURN                                                   ~0
   23     2*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FGqjpZ%3A21%245

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.73 ms | 1400 KiB | 15 Q