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); }; } var_dump(add(2)); echo add(2)->__invoke(40)->__invoke();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LAcC3
function name:  (null)
number of ops:  16
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'add'
          2        SEND_VAL                                                 2
          3        DO_FCALL                                      0  $0      
          4        SEND_VAR                                                 $0
          5        DO_ICALL                                                 
   11     6        INIT_FCALL                                               'add'
          7        SEND_VAL                                                 2
          8        DO_FCALL                                      0  $2      
          9        INIT_METHOD_CALL                                         $2, '__invoke'
         10        SEND_VAL_EX                                              40
         11        DO_FCALL                                      0  $3      
         12        INIT_METHOD_CALL                                         $3, '__invoke'
         13        DO_FCALL                                      0  $4      
         14        ECHO                                                     $4
         15      > RETURN                                                   1

Function add:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LAcC3
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%2FLAcC3%3A4%240'
          2        BIND_LEXICAL                                             ~1, !0
    8     3      > RETURN                                                   ~1
    9     4*     > RETURN                                                   null

End of function add

Function %00%7Bclosure%7D%2Fin%2FLAcC3%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/LAcC3
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%2FLAcC3%3A4%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.49 ms | 1403 KiB | 17 Q