3v4l.org

run code in 300+ PHP versions simultaneously
<?php function curry(\Closure $f, $params = []) { return function() use($f, $params) { $refl = new ReflectionFunction($f); $arity = $refl->getNumberOfParameters(); $args = array_merge($params, func_get_args()); return (count($args) >= $arity) ? call_user_func_array($f, $args) : curry($f, $args); }; }; // ================================================== $abc = function($a, $b, $c) { return [$a, $b ,$c]; }; $cur = curry($abc); $res = $cur(1)(2)(3); //$res1 = $cur (1); //$res2 = $res1(2); //$res3 = $res2(3); // var_dump($res);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/l6BGY
function name:  (null)
number of ops:  20
compiled vars:  !0 = $abc, !1 = $cur, !2 = $res
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Fl6BGY%3A15%241'
          1        ASSIGN                                                   !0, ~3
   19     2        INIT_FCALL                                               'curry'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $5      
          5        ASSIGN                                                   !1, $5
   20     6        INIT_DYNAMIC_CALL                                        !1
          7        SEND_VAL_EX                                              1
          8        DO_FCALL                                      0  $7      
          9        INIT_DYNAMIC_CALL                                        $7
         10        SEND_VAL_EX                                              2
         11        DO_FCALL                                      0  $8      
         12        INIT_DYNAMIC_CALL                                        $8
         13        SEND_VAL_EX                                              3
         14        DO_FCALL                                      0  $9      
         15        ASSIGN                                                   !2, $9
   26    16        INIT_FCALL                                               'var_dump'
         17        SEND_VAR                                                 !2
         18        DO_ICALL                                                 
         19      > RETURN                                                   1

Function curry:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/l6BGY
function name:  curry
number of ops:  7
compiled vars:  !0 = $f, !1 = $params
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      <array>
    4     2        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Fl6BGY%3A4%240'
          3        BIND_LEXICAL                                             ~2, !0
          4        BIND_LEXICAL                                             ~2, !1
   10     5      > RETURN                                                   ~2
   11     6*     > RETURN                                                   null

End of function curry

Function %00%7Bclosure%7D%2Fin%2Fl6BGY%3A4%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 24
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/l6BGY
function name:  {closure}
number of ops:  31
compiled vars:  !0 = $f, !1 = $params, !2 = $refl, !3 = $arity, !4 = $args
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   BIND_STATIC                                              !0
          1        BIND_STATIC                                              !1
    5     2        NEW                                              $5      'ReflectionFunction'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !2, $5
    6     6        INIT_METHOD_CALL                                         !2, 'getNumberOfParameters'
          7        DO_FCALL                                      0  $8      
          8        ASSIGN                                                   !3, $8
    7     9        INIT_FCALL                                               'array_merge'
         10        SEND_VAR                                                 !1
         11        FUNC_GET_ARGS                                    ~10     
         12        SEND_VAL                                                 ~10
         13        DO_ICALL                                         $11     
         14        ASSIGN                                                   !4, $11
    9    15        COUNT                                            ~13     !4
         16        IS_SMALLER_OR_EQUAL                                      !3, ~13
         17      > JMPZ                                                     ~14, ->24
         18    >   INIT_USER_CALL                                0          'call_user_func_array', !0
         19        SEND_ARRAY                                               !4
         20        CHECK_UNDEF_ARGS                                         
         21        DO_FCALL                                      0  $15     
         22        QM_ASSIGN                                        ~16     $15
         23      > JMP                                                      ->29
         24    >   INIT_FCALL_BY_NAME                                       'curry'
         25        SEND_VAR_EX                                              !0
         26        SEND_VAR_EX                                              !4
         27        DO_FCALL                                      0  $17     
         28        QM_ASSIGN                                        ~16     $17
         29    > > RETURN                                                   ~16
   10    30*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Fl6BGY%3A4%240

Function %00%7Bclosure%7D%2Fin%2Fl6BGY%3A15%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/l6BGY
function name:  {closure}
number of ops:  8
compiled vars:  !0 = $a, !1 = $b, !2 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   16     3        INIT_ARRAY                                       ~3      !0
          4        ADD_ARRAY_ELEMENT                                ~3      !1
          5        ADD_ARRAY_ELEMENT                                ~3      !2
          6      > RETURN                                                   ~3
   17     7*     > RETURN                                                   null

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

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
166.56 ms | 1403 KiB | 18 Q