3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $matchesMatches = function ($matches) { //$m = 1; //yield $m; // could put as a `for` so it is more optimized, but for now, that is premature optimization foreach ($matches as $match) { var_dump($match); // yeild $m; for ($i = 1; $i <= 3; $i++) { // Note that $i is preserved between yields. yield $i; } } }; $matches = [1,2, 3]; $matches = [1 => array('a', 'b'), 2 => array('c', 'd'), 3 => array('e', 'f')]; foreach ($matchesMatches($matches) as $m) { var_dump($m); }
based on RnECR
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = 8, Position 2 = 13
Branch analysis from position: 8
Jump found. Position 1 = 9, Position 2 = 13
Branch analysis from position: 9
Jump found. Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 13
Jump found. Position 1 = -2
Branch analysis from position: 13
filename:       /in/LDdRc
function name:  (null)
number of ops:  15
compiled vars:  !0 = $matchesMatches, !1 = $matches, !2 = $m
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   4     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FLDdRc0x7f392cbe125b'
  18     1        ASSIGN                                                   !0, ~3
  20     2        ASSIGN                                                   !1, <array>
  21     3        ASSIGN                                                   !1, <array>
  22     4        INIT_DYNAMIC_CALL                                        !0
         5        SEND_VAR_EX                                              !1
         6        DO_FCALL                                      0  $7      
         7      > FE_RESET_R                                       $8      $7, ->13
         8    > > FE_FETCH_R                                               $8, !2, ->13
  23     9    >   INIT_FCALL                                               'var_dump'
        10        SEND_VAR                                                 !2
        11        DO_ICALL                                                 
        12      > JMP                                                      ->8
        13    >   FE_FREE                                                  $8
        14      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FLDdRc0x7f392cbe125b:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = 2, Position 2 = 14
Branch analysis from position: 2
Jump found. Position 1 = 3, Position 2 = 14
Branch analysis from position: 3
Jump found. Position 1 = 11
Branch analysis from position: 11
Jump found. Position 1 = 13, Position 2 = 8
Branch analysis from position: 13
Jump found. Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 8
Jump found. Position 1 = 13, Position 2 = 8
Branch analysis from position: 13
Branch analysis from position: 8
Branch analysis from position: 14
Jump found. Position 1 = -2
Branch analysis from position: 14
filename:       /in/LDdRc
function name:  {closure}
number of ops:  16
compiled vars:  !0 = $matches, !1 = $match, !2 = $i
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   4     0  E >   RECV                                             !0      
  10     1      > FE_RESET_R                                       $3      !0, ->14
         2    > > FE_FETCH_R                                               $3, !1, ->14
  11     3    >   INIT_FCALL                                               'var_dump'
         4        SEND_VAR                                                 !1
         5        DO_ICALL                                                 
  13     6        ASSIGN                                                   !2, 1
         7      > JMP                                                      ->11
  15     8    >   YIELD                                                    !2
  13     9        POST_INC                                         ~7      !2
        10        FREE                                                     ~7
        11    >   IS_SMALLER_OR_EQUAL                              ~8      !2, 3
        12      > JMPNZ                                                    ~8, ->8
        13    > > JMP                                                      ->2
        14    >   FE_FREE                                                  $3
  18    15      > GENERATOR_RETURN                                         

End of function %00%7Bclosure%7D%2Fin%2FLDdRc0x7f392cbe125b

Generated using Vulcan Logic Dumper, using php 7.3.0