3v4l.org

run code in 300+ PHP versions simultaneously
<?php function arity($lambda) { $r = new ReflectionObject($lambda); $m = $r->getMethod('__invoke'); return $m->getNumberOfParameters(); } print arity(function($foo, $bar, $baz) { });
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6KPFN
function name:  (null)
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   INIT_FCALL                                               'arity'
          1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F6KPFN%3A9%240'
   10     2        SEND_VAL                                                 ~0
          3        DO_FCALL                                      0  $1      
          4        ECHO                                                     $1
          5      > RETURN                                                   1

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

End of function arity

Function %00%7Bclosure%7D%2Fin%2F6KPFN%3A9%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6KPFN
function name:  {closure}
number of ops:  4
compiled vars:  !0 = $foo, !1 = $bar, !2 = $baz
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   10     3      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F6KPFN%3A9%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.33 ms | 1399 KiB | 14 Q