3v4l.org

run code in 300+ PHP versions simultaneously
<?php function yieldFromIteratorGeneratorThrows() { try { yield from new class(new ArrayIterator([1, -2])) extends IteratorIterator { public function key() { if ($k = parent::key()) { throw new Exception; } return $k; } }; } catch (Exception $e) { yield 2; } } foreach (yieldFromIteratorGeneratorThrows() as $k => $v) { var_dump($v); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 9
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 9
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
filename:       /in/pvIjH
function name:  (null)
number of ops:  11
compiled vars:  !0 = $v, !1 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   INIT_FCALL                                               'yieldfromiteratorgeneratorthrows'
          1        DO_FCALL                                      0  $2      
          2      > FE_RESET_R                                       $3      $2, ->9
          3    > > FE_FETCH_R                                       ~4      $3, !0, ->9
          4    >   ASSIGN                                                   !1, ~4
   19     5        INIT_FCALL                                               'var_dump'
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                                 
   18     8      > JMP                                                      ->3
          9    >   FE_FREE                                                  $3
   20    10      > RETURN                                                   1

Function yieldfromiteratorgeneratorthrows:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
1 jumps found. (Code = 161) Position 1 = -2
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 = 161) Position 1 = -2
filename:       /in/pvIjH
function name:  yieldFromIteratorGeneratorThrows
number of ops:  14
compiled vars:  !0 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   GENERATOR_CREATE                                         
    5     1        DECLARE_ANON_CLASS                               <unknown> 'iteratoriterator'
          2        NEW                                              $2      $1
          3        NEW                                              $3      'ArrayIterator'
          4        SEND_VAL_EX                                              <array>
          5        DO_FCALL                                      0          
          6        SEND_VAR_NO_REF_EX                                       $3
          7        DO_FCALL                                      0          
          8        YIELD_FROM                                       ~6      $2
          9        FREE                                                     ~6
         10      > JMP                                                      ->13
   13    11  E > > CATCH                                       last         'Exception'
   14    12    >   YIELD                                                    2
   16    13    > > GENERATOR_RETURN                                         

End of function yieldfromiteratorgeneratorthrows

Class IteratorIterator@anonymous:
Function key:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 7
Branch analysis from position: 4
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pvIjH
function name:  key
number of ops:  9
compiled vars:  !0 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   INIT_STATIC_METHOD_CALL                                  'key'
          1        DO_FCALL                                      0  $1      
          2        ASSIGN                                           ~2      !0, $1
          3      > JMPZ                                                     ~2, ->7
    8     4    >   NEW                                              $3      'Exception'
          5        DO_FCALL                                      0          
          6      > THROW                                         0          $3
   10     7    > > RETURN                                                   !0
   11     8*     > RETURN                                                   null

End of function key

End of class IteratorIterator@anonymous.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.8 ms | 1017 KiB | 15 Q