3v4l.org

run code in 300+ PHP versions simultaneously
<?php function test(callable $fn){ $reflection = new ReflectionFunction($fn); $args = count($reflection->getParameters()); $curried = function(...$currArgs) use($args, $fn){ if(count($currArgs) == $args){ return $fn(...$currArgs); }else{ return function(...$currArgs2) use($args, $fn, $currArgs){ return $curried(array_merge($currArgs, $currArgs2)); }; } }; return $curried; } $c = test(fn($x, $y, $z) => $x + $y + $z); echo $c(10)(20,30);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PQsrh
function name:  (null)
number of ops:  14
compiled vars:  !0 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   INIT_FCALL                                               'test'
          1        DECLARE_LAMBDA_FUNCTION                          ~1      [0]
          2        SEND_VAL                                                 ~1
          3        DO_FCALL                                      0  $2      
          4        ASSIGN                                                   !0, $2
   24     5        INIT_DYNAMIC_CALL                                        !0
          6        SEND_VAL_EX                                              10
          7        DO_FCALL                                      0  $4      
          8        INIT_DYNAMIC_CALL                                        $4
          9        SEND_VAL_EX                                              20
         10        SEND_VAL_EX                                              30
         11        DO_FCALL                                      0  $5      
         12        ECHO                                                     $5
         13      > 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/PQsrh
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $x, !1 = $y, !2 = $z
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        ADD                                              ~3      !0, !1
          4        ADD                                              ~4      ~3, !2
          5      > RETURN                                                   ~4
          6*     > RETURN                                                   null

End of Dynamic Function 0

Function test:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PQsrh
function name:  test
number of ops:  15
compiled vars:  !0 = $fn, !1 = $reflection, !2 = $args, !3 = $curried
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        NEW                                              $4      'ReflectionFunction'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !1, $4
    5     5        INIT_METHOD_CALL                                         !1, 'getParameters'
          6        DO_FCALL                                      0  $7      
          7        COUNT                                            ~8      $7
          8        ASSIGN                                                   !2, ~8
    7     9        DECLARE_LAMBDA_FUNCTION                          ~10     [0]
         10        BIND_LEXICAL                                             ~10, !2
         11        BIND_LEXICAL                                             ~10, !0
         12        ASSIGN                                                   !3, ~10
   17    13      > RETURN                                                   !3
   18    14*     > RETURN                                                   null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 12
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PQsrh
function name:  {closure}
number of ops:  18
compiled vars:  !0 = $currArgs, !1 = $args, !2 = $fn
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV_VARIADIC                                    !0      
          1        BIND_STATIC                                              !1
          2        BIND_STATIC                                              !2
    8     3        COUNT                                            ~3      !0
          4        IS_EQUAL                                                 !1, ~3
          5      > JMPZ                                                     ~4, ->12
    9     6    >   INIT_DYNAMIC_CALL                                        !2
          7        SEND_UNPACK                                              !0
          8        CHECK_UNDEF_ARGS                                         
          9        DO_FCALL                                      1  $5      
         10      > RETURN                                                   $5
    8    11*       JMP                                                      ->17
   11    12    >   DECLARE_LAMBDA_FUNCTION                          ~6      [0]
         13        BIND_LEXICAL                                             ~6, !1
         14        BIND_LEXICAL                                             ~6, !2
         15        BIND_LEXICAL                                             ~6, !0
   13    16      > RETURN                                                   ~6
   15    17*     > 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/PQsrh
function name:  {closure}
number of ops:  13
compiled vars:  !0 = $currArgs2, !1 = $args, !2 = $fn, !3 = $currArgs, !4 = $curried
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV_VARIADIC                                    !0      
          1        BIND_STATIC                                              !1
          2        BIND_STATIC                                              !2
          3        BIND_STATIC                                              !3
   12     4        INIT_DYNAMIC_CALL                                        !4
          5        INIT_FCALL                                               'array_merge'
          6        SEND_VAR                                                 !3
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                         $5      
          9        SEND_VAR_NO_REF_EX                                       $5
         10        DO_FCALL                                      0  $6      
         11      > RETURN                                                   $6
   13    12*     > RETURN                                                   null

End of Dynamic Function 0

End of Dynamic Function 0

End of function test

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.01 ms | 1452 KiB | 15 Q