3v4l.org

run code in 300+ PHP versions simultaneously
<?php function add($x) { return function($y = null) use ($x) { if (is_null($y)) return $x; else return add($x + $y); }; } echo add(2)->__invoke(40)->__invoke();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/QcN7h
function name:  (null)
number of ops:  10
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   INIT_FCALL                                               'add'
          1        SEND_VAL                                                 2
          2        DO_FCALL                                      0  $0      
          3        INIT_METHOD_CALL                                         $0, '__invoke'
          4        SEND_VAL_EX                                              40
          5        DO_FCALL                                      0  $1      
          6        INIT_METHOD_CALL                                         $1, '__invoke'
          7        DO_FCALL                                      0  $2      
          8        ECHO                                                     $2
          9      > RETURN                                                   1

Function add:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/QcN7h
function name:  add
number of ops:  5
compiled vars:  !0 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    4     1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FQcN7h%3A4%240'
          2        BIND_LEXICAL                                             ~1, !0
    8     3      > RETURN                                                   ~1
    9     4*     > RETURN                                                   null

End of function add

Function %00%7Bclosure%7D%2Fin%2FQcN7h%3A4%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 6
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/QcN7h
function name:  {closure}
number of ops:  12
compiled vars:  !0 = $y, !1 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV_INIT                                        !0      null
          1        BIND_STATIC                                              !1
    6     2        TYPE_CHECK                                    2          !0
          3      > JMPZ                                                     ~2, ->6
          4    > > RETURN                                                   !1
          5*       JMP                                                      ->11
    7     6    >   INIT_FCALL_BY_NAME                                       'add'
          7        ADD                                              ~3      !1, !0
          8        SEND_VAL_EX                                              ~3
          9        DO_FCALL                                      0  $4      
         10      > RETURN                                                   $4
    8    11*     > RETURN                                                   null

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

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.52 ms | 1398 KiB | 14 Q