3v4l.org

run code in 300+ PHP versions simultaneously
<?php function executeFns(Generator $fnProvider, $args = []) { $lastResult = 0; while ($fnProvider->valid()) { try { $fn = $fnProvider->current(); $lastResult = $fn($lastResult); $fnProvider->send($lastResult); } catch (Exception $e) { $fnProvider->throw($e); } } } $fns = [ function ($n) { return $n + 1; }, function ($n) { return $n + 2; }, function ($n) { return $n + 3; }, function ($n) { return $n + 4; }, function ($n) { throw new Exception('Throwin\' \'cepshuns, just cuz!'); } ]; function debuggingFnProvider(array $fns) { foreach ($fns as $fn) { try { $result = (yield $fn); echo "Result: {$result}\n"; } catch (Exception $e) { echo "Error: " . $e->getMessage() . "\n"; } } } executeFns(debuggingFnProvider($fns));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/c6CpN
function name:  (null)
number of ops:  18
compiled vars:  !0 = $fns
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Fc6CpN%3A18%240'
          1        INIT_ARRAY                                       ~2      ~1
   19     2        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Fc6CpN%3A19%241'
          3        ADD_ARRAY_ELEMENT                                ~2      ~3
   20     4        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Fc6CpN%3A20%242'
          5        ADD_ARRAY_ELEMENT                                ~2      ~4
   21     6        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Fc6CpN%3A21%243'
          7        ADD_ARRAY_ELEMENT                                ~2      ~5
   22     8        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Fc6CpN%3A22%244'
          9        ADD_ARRAY_ELEMENT                                ~2      ~6
   17    10        ASSIGN                                                   !0, ~2
   37    11        INIT_FCALL                                               'executefns'
         12        INIT_FCALL                                               'debuggingfnprovider'
         13        SEND_VAR                                                 !0
         14        DO_FCALL                                      0  $8      
         15        SEND_VAR                                                 $8
         16        DO_FCALL                                      0          
         17      > RETURN                                                   1

Function executefns:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
2 jumps found. (Code = 44) Position 1 = 22, Position 2 = 4
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
Found catch point at position: 15
Branch analysis from position: 15
2 jumps found. (Code = 107) Position 1 = 16, Position 2 = -2
Branch analysis from position: 16
2 jumps found. (Code = 44) Position 1 = 22, Position 2 = 4
Branch analysis from position: 22
Branch analysis from position: 4
filename:       /in/c6CpN
function name:  executeFns
number of ops:  23
compiled vars:  !0 = $fnProvider, !1 = $args, !2 = $lastResult, !3 = $fn, !4 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      <array>
    5     2        ASSIGN                                                   !2, 0
    6     3      > JMP                                                      ->19
    8     4    >   INIT_METHOD_CALL                                         !0, 'current'
          5        DO_FCALL                                      0  $6      
          6        ASSIGN                                                   !3, $6
    9     7        INIT_DYNAMIC_CALL                                        !3
          8        SEND_VAR_EX                                              !2
          9        DO_FCALL                                      0  $8      
         10        ASSIGN                                                   !2, $8
   10    11        INIT_METHOD_CALL                                         !0, 'send'
         12        SEND_VAR_EX                                              !2
         13        DO_FCALL                                      0          
         14      > JMP                                                      ->19
   11    15  E > > CATCH                                       last         'Exception'
   12    16    >   INIT_METHOD_CALL                                         !0, 'throw'
         17        SEND_VAR_EX                                              !4
         18        DO_FCALL                                      0          
    6    19    >   INIT_METHOD_CALL                                         !0, 'valid'
         20        DO_FCALL                                      0  $12     
         21      > JMPNZ                                                    $12, ->4
   15    22    > > RETURN                                                   null

End of function executefns

Function %00%7Bclosure%7D%2Fin%2Fc6CpN%3A18%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/c6CpN
function name:  {closure}
number of ops:  4
compiled vars:  !0 = $n
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
          1        ADD                                              ~1      !0, 1
          2      > RETURN                                                   ~1
          3*     > RETURN                                                   null

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

Function %00%7Bclosure%7D%2Fin%2Fc6CpN%3A19%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/c6CpN
function name:  {closure}
number of ops:  4
compiled vars:  !0 = $n
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   RECV                                             !0      
          1        ADD                                              ~1      !0, 2
          2      > RETURN                                                   ~1
          3*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Fc6CpN%3A19%241

Function %00%7Bclosure%7D%2Fin%2Fc6CpN%3A20%242:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/c6CpN
function name:  {closure}
number of ops:  4
compiled vars:  !0 = $n
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
          1        ADD                                              ~1      !0, 3
          2      > RETURN                                                   ~1
          3*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Fc6CpN%3A20%242

Function %00%7Bclosure%7D%2Fin%2Fc6CpN%3A21%243:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/c6CpN
function name:  {closure}
number of ops:  4
compiled vars:  !0 = $n
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   RECV                                             !0      
          1        ADD                                              ~1      !0, 4
          2      > RETURN                                                   ~1
          3*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Fc6CpN%3A21%243

Function %00%7Bclosure%7D%2Fin%2Fc6CpN%3A22%244:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 108) Position 1 = -2
filename:       /in/c6CpN
function name:  {closure}
number of ops:  6
compiled vars:  !0 = $n
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   RECV                                             !0      
          1        NEW                                              $1      'Exception'
          2        SEND_VAL_EX                                              'Throwin%27+%27cepshuns%2C+just+cuz%21'
          3        DO_FCALL                                      0          
          4      > THROW                                         0          $1
          5*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Fc6CpN%3A22%244

Function debuggingfnprovider:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 18
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 18
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 18
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 18
Found catch point at position: 11
Branch analysis from position: 11
2 jumps found. (Code = 107) Position 1 = 12, Position 2 = -2
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
filename:       /in/c6CpN
function name:  debuggingFnProvider
number of ops:  20
compiled vars:  !0 = $fns, !1 = $fn, !2 = $result, !3 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   RECV                                             !0      
          1        GENERATOR_CREATE                                         
   27     2      > FE_RESET_R                                       $4      !0, ->18
          3    > > FE_FETCH_R                                               $4, !1, ->18
   29     4    >   YIELD                                            $5      !1
          5        ASSIGN                                                   !2, $5
   30     6        ROPE_INIT                                     3  ~8      'Result%3A+'
          7        ROPE_ADD                                      1  ~8      ~8, !2
          8        ROPE_END                                      2  ~7      ~8, '%0A'
          9        ECHO                                                     ~7
         10      > JMP                                                      ->17
   31    11  E > > CATCH                                       last         'Exception'
   32    12    >   INIT_METHOD_CALL                                         !3, 'getMessage'
         13        DO_FCALL                                      0  $10     
         14        CONCAT                                           ~11     'Error%3A+', $10
         15        CONCAT                                           ~12     ~11, '%0A'
         16        ECHO                                                     ~12
   27    17    > > JMP                                                      ->3
         18    >   FE_FREE                                                  $4
   35    19      > GENERATOR_RETURN                                         

End of function debuggingfnprovider

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.42 ms | 1407 KiB | 15 Q