3v4l.org

run code in 300+ PHP versions simultaneously
<?php global $hook; $hook = function ( &$reference ) { echo "ok\n"; }; $wrap = function() { $user = []; $params = [ &$user ]; $f = function () use ( $params ) { global $hook; call_user_func_array( $hook, $params ); }; echo "inner\n"; call_user_func( $f ); // works return $f; }; $f = $wrap(); echo "outer\n"; call_user_func( $f ); // fails
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XbNo3
function name:  (null)
number of ops:  12
compiled vars:  !0 = $hook, !1 = $wrap, !2 = $f
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   BIND_GLOBAL                                              !0, 'hook'
    4     1        DECLARE_LAMBDA_FUNCTION                          ~3      [0]
          2        ASSIGN                                                   !0, ~3
    6     3        DECLARE_LAMBDA_FUNCTION                          ~5      [1]
          4        ASSIGN                                                   !1, ~5
   17     5        INIT_DYNAMIC_CALL                                        !1
          6        DO_FCALL                                      0  $7      
          7        ASSIGN                                                   !2, $7
   18     8        ECHO                                                     'outer%0A'
          9        INIT_USER_CALL                                0          'call_user_func', !2
         10        DO_FCALL                                      0          
         11      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XbNo3
function name:  {closure}
number of ops:  3
compiled vars:  !0 = $reference
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
          1        ECHO                                                     'ok%0A'
          2      > RETURN                                                   null

End of Dynamic Function 0

Dynamic Function 1
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XbNo3
function name:  {closure}
number of ops:  11
compiled vars:  !0 = $user, !1 = $params, !2 = $f
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   ASSIGN                                                   !0, <array>
    8     1        INIT_ARRAY                                       ~4      !0
          2        ASSIGN                                                   !1, ~4
    9     3        DECLARE_LAMBDA_FUNCTION                          ~6      [0]
          4        BIND_LEXICAL                                             ~6, !1
          5        ASSIGN                                                   !2, ~6
   13     6        ECHO                                                     'inner%0A'
          7        INIT_USER_CALL                                0          'call_user_func', !2
          8        DO_FCALL                                      0          
   14     9      > RETURN                                                   !2
   15    10*     > RETURN                                                   null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XbNo3
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $params, !1 = $hook
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   BIND_STATIC                                              !0
   10     1        BIND_GLOBAL                                              !1, 'hook'
   11     2        INIT_USER_CALL                                0          'call_user_func_array', !1
          3        SEND_ARRAY                                               !0
          4        CHECK_UNDEF_ARGS                                         
          5        DO_FCALL                                      1          
   12     6      > RETURN                                                   null

End of Dynamic Function 0

End of Dynamic Function 1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
123.99 ms | 1447 KiB | 13 Q