3v4l.org

run code in 500+ PHP versions simultaneously
<?php function arity(callable $f): int { $ref = new ReflectionFunction($f); return $ref->getNumberOfParameters(); } var_dump(arity(fn() => null)); var_dump(arity(fn($a) => null)); var_dump(arity(fn($a, $b) => null)); var_dump(arity(fn($a, ...$args) => null)); var_dump(arity(fn(...$args) => null));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/e6to8
function name:  (null)
number of ops:  36
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   10     0  E >   INIT_FCALL                                                   'var_dump'
          1        INIT_FCALL                                                   'arity'
          2        DECLARE_LAMBDA_FUNCTION                              ~0      [0]
          3        SEND_VAL                                                     ~0
          4        DO_FCALL                                          0  $1      
          5        SEND_VAR                                                     $1
          6        DO_ICALL                                                     
   11     7        INIT_FCALL                                                   'var_dump'
          8        INIT_FCALL                                                   'arity'
          9        DECLARE_LAMBDA_FUNCTION                              ~3      [1]
         10        SEND_VAL                                                     ~3
         11        DO_FCALL                                          0  $4      
         12        SEND_VAR                                                     $4
         13        DO_ICALL                                                     
   12    14        INIT_FCALL                                                   'var_dump'
         15        INIT_FCALL                                                   'arity'
         16        DECLARE_LAMBDA_FUNCTION                              ~6      [2]
         17        SEND_VAL                                                     ~6
         18        DO_FCALL                                          0  $7      
         19        SEND_VAR                                                     $7
         20        DO_ICALL                                                     
   13    21        INIT_FCALL                                                   'var_dump'
         22        INIT_FCALL                                                   'arity'
         23        DECLARE_LAMBDA_FUNCTION                              ~9      [3]
         24        SEND_VAL                                                     ~9
         25        DO_FCALL                                          0  $10     
         26        SEND_VAR                                                     $10
         27        DO_ICALL                                                     
   14    28        INIT_FCALL                                                   'var_dump'
         29        INIT_FCALL                                                   'arity'
         30        DECLARE_LAMBDA_FUNCTION                              ~12     [4]
         31        SEND_VAL                                                     ~12
         32        DO_FCALL                                          0  $13     
         33        SEND_VAR                                                     $13
         34        DO_ICALL                                                     
         35      > 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/e6to8
function name:  {closure:/in/e6to8:10}
number of ops:  2
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   10     0  E > > RETURN                                                       null
          1*     > 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/e6to8
function name:  {closure:/in/e6to8:11}
number of ops:  3
compiled vars:  !0 = $a
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   11     0  E >   RECV                                                 !0      
          1      > RETURN                                                       null
          2*     > RETURN                                                       null

End of Dynamic Function 1

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

End of Dynamic Function 2

Dynamic Function 3
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/e6to8
function name:  {closure:/in/e6to8:13}
number of ops:  4
compiled vars:  !0 = $a, !1 = $args
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   13     0  E >   RECV                                                 !0      
          1        RECV_VARIADIC                                        !1      
          2      > RETURN                                                       null
          3*     > RETURN                                                       null

End of Dynamic Function 3

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

End of Dynamic Function 4

Function arity:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/e6to8
function name:  arity
number of ops:  11
compiled vars:  !0 = $f, !1 = $ref
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   RECV                                                 !0      
    5     1        NEW                                                  $2      'ReflectionFunction'
          2        SEND_VAR_EX                                                  !0
          3        DO_FCALL                                          0          
          4        ASSIGN                                                       !1, $2
    7     5        INIT_METHOD_CALL                                             !1, 'getNumberOfParameters'
          6        DO_FCALL                                          0  $5      
          7        VERIFY_RETURN_TYPE                                           $5
          8      > RETURN                                                       $5
    8     9*       VERIFY_RETURN_TYPE                                           
         10*     > RETURN                                                       null

End of function arity

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
187.8 ms | 1161 KiB | 14 Q