3v4l.org

run code in 300+ PHP versions simultaneously
<?php function retry($retries, callable $fn) { beginning: try { return $fn(); } catch (\Exception $e) { if (!$retries) { throw new \Exception('', 0, $e); } $retries--; goto beginning; } } $fn = function() { if (mt_rand(0, 5) === 0) { return true; } throw new \Exception('nope'); }; retry(10, $fn);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/d27PS
function name:  (null)
number of ops:  7
compiled vars:  !0 = $fn
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Fd27PS%3A18%240'
          1        ASSIGN                                                   !0, ~1
   25     2        INIT_FCALL                                               'retry'
          3        SEND_VAL                                                 10
          4        SEND_VAR                                                 !0
          5        DO_FCALL                                      0          
          6      > RETURN                                                   1

Function retry:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
Found catch point at position: 7
Branch analysis from position: 7
2 jumps found. (Code = 107) Position 1 = 8, Position 2 = -2
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 16
Branch analysis from position: 10
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
filename:       /in/d27PS
function name:  retry
number of ops:  19
compiled vars:  !0 = $retries, !1 = $fn, !2 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    7     2    >   NOP                                                      
    8     3        INIT_DYNAMIC_CALL                                        !1
          4        DO_FCALL                                      0  $3      
          5      > RETURN                                                   $3
          6*       JMP                                                      ->18
    9     7  E > > CATCH                                       last         'Exception'
   10     8    >   BOOL_NOT                                         ~4      !0
          9      > JMPZ                                                     ~4, ->16
   11    10    >   NEW                                              $5      'Exception'
         11        SEND_VAL_EX                                              ''
         12        SEND_VAL_EX                                              0
         13        SEND_VAR_EX                                              !2
         14        DO_FCALL                                      0          
         15      > THROW                                         0          $5
   13    16    >   PRE_DEC                                                  !0
   14    17      > JMP                                                      ->2
   16    18*     > RETURN                                                   null

End of function retry

Function %00%7Bclosure%7D%2Fin%2Fd27PS%3A18%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 7
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
1 jumps found. (Code = 108) Position 1 = -2
filename:       /in/d27PS
function name:  {closure}
number of ops:  12
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   INIT_FCALL                                               'mt_rand'
          1        SEND_VAL                                                 0
          2        SEND_VAL                                                 5
          3        DO_ICALL                                         $0      
          4        IS_IDENTICAL                                             $0, 0
          5      > JMPZ                                                     ~1, ->7
   21     6    > > RETURN                                                   <true>
   23     7    >   NEW                                              $2      'Exception'
          8        SEND_VAL_EX                                              'nope'
          9        DO_FCALL                                      0          
         10      > THROW                                         0          $2
   24    11*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Fd27PS%3A18%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
173.23 ms | 1403 KiB | 16 Q