3v4l.org

run code in 500+ PHP versions simultaneously
<?php function curry($f, ...$argsCurried) { return function(...$args) use($f, $argsCurried) { $finalArgs = array_merge($argsCurried, $args); return call_user_func_array($f, $finalArgs); }; } function add($n1, $n2) { return $n1 + $n2; } $addFive = curry('add', 5); echo $addFive(2), PHP_EOL; echo $addFive(-5), PHP_EOL;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VufKK
function name:  (null)
number of ops:  16
compiled vars:  !0 = $addFive
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   14     0  E >   INIT_FCALL                                                   'curry'
          1        SEND_VAL                                                     'add'
          2        SEND_VAL                                                     5
          3        DO_FCALL                                          0  $1      
          4        ASSIGN                                                       !0, $1
   16     5        INIT_DYNAMIC_CALL                                            !0
          6        SEND_VAL_EX                                                  2
          7        DO_FCALL                                          0  $3      
          8        ECHO                                                         $3
          9        ECHO                                                         '%0A'
   17    10        INIT_DYNAMIC_CALL                                            !0
         11        SEND_VAL_EX                                                  -5
         12        DO_FCALL                                          0  $4      
         13        ECHO                                                         $4
         14        ECHO                                                         '%0A'
   18    15      > RETURN                                                       1

Function curry:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VufKK
function name:  curry
number of ops:  7
compiled vars:  !0 = $f, !1 = $argsCurried
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   RECV                                                 !0      
          1        RECV_VARIADIC                                        !1      
    4     2        DECLARE_LAMBDA_FUNCTION                              ~2      [0]
          3        BIND_LEXICAL                                                 ~2, !0
          4        BIND_LEXICAL                                                 ~2, !1
    7     5      > RETURN                                                       ~2
    8     6*     > 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/VufKK
function name:  {closure:curry():4}
number of ops:  14
compiled vars:  !0 = $args, !1 = $f, !2 = $argsCurried, !3 = $finalArgs
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    4     0  E >   RECV_VARIADIC                                        !0      
          1        BIND_STATIC                                                  !1
          2        BIND_STATIC                                                  !2
    5     3        INIT_FCALL                                                   'array_merge'
          4        SEND_VAR                                                     !2
          5        SEND_VAR                                                     !0
          6        DO_ICALL                                             $4      
          7        ASSIGN                                                       !3, $4
    6     8        INIT_USER_CALL                                    0          'call_user_func_array', !1
          9        SEND_ARRAY                                                   !3
         10        CHECK_UNDEF_ARGS                                             
         11        DO_FCALL                                          1  $6      
         12      > RETURN                                                       $6
    7    13*     > RETURN                                                       null

End of Dynamic Function 0

End of function curry

Function add:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VufKK
function name:  add
number of ops:  5
compiled vars:  !0 = $n1, !1 = $n2
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   10     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
   11     2        ADD                                                  ~2      !0, !1
          3      > RETURN                                                       ~2
   12     4*     > RETURN                                                       null

End of function add

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
162.06 ms | 2104 KiB | 15 Q