3v4l.org

run code in 300+ PHP versions simultaneously
<?php function uppercase(Traversable $in) { foreach ($in as $word) { yield strtoupper($word); } } function reverse(Traversable $in) { foreach ($in as $word) { yield strrev($word); } } function each_println(Traversable $in) { foreach ($in as $line) { echo "$line\n"; } } function allAbove(Traversable $in) { foreach($in as $word) { yield array('upper' => strtoupper($word), 'rev' => strrev($word), 'combined' => strrev(strtoupper($word))); } } each_println(reverse(uppercase(new ArrayIterator(["foo", "bar", "baz"])))); foreach(allAbove(new ArrayIterator(["foo", "bar", "baz"])) as $item) { each_println(new ArrayIterator($item)); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 19, Position 2 = 27
Branch analysis from position: 19
2 jumps found. (Code = 78) Position 1 = 20, Position 2 = 27
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
filename:       /in/hDRK5
function name:  (null)
number of ops:  29
compiled vars:  !0 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   INIT_FCALL                                               'each_println'
          1        INIT_FCALL                                               'reverse'
          2        INIT_FCALL                                               'uppercase'
          3        NEW                                              $1      'ArrayIterator'
          4        SEND_VAL_EX                                              <array>
          5        DO_FCALL                                      0          
          6        SEND_VAR                                                 $1
          7        DO_FCALL                                      0  $3      
          8        SEND_VAR                                                 $3
          9        DO_FCALL                                      0  $4      
         10        SEND_VAR                                                 $4
         11        DO_FCALL                                      0          
   32    12        INIT_FCALL                                               'allabove'
         13        NEW                                              $6      'ArrayIterator'
         14        SEND_VAL_EX                                              <array>
         15        DO_FCALL                                      0          
         16        SEND_VAR                                                 $6
         17        DO_FCALL                                      0  $8      
         18      > FE_RESET_R                                       $9      $8, ->27
         19    > > FE_FETCH_R                                               $9, !0, ->27
   33    20    >   INIT_FCALL                                               'each_println'
         21        NEW                                              $10     'ArrayIterator'
         22        SEND_VAR_EX                                              !0
         23        DO_FCALL                                      0          
         24        SEND_VAR                                                 $10
         25        DO_FCALL                                      0          
   32    26      > JMP                                                      ->19
         27    >   FE_FREE                                                  $9
   34    28      > RETURN                                                   1

Function uppercase:
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 = 161) Position 1 = -2
Branch analysis from position: 9
filename:       /in/hDRK5
function name:  uppercase
number of ops:  11
compiled vars:  !0 = $in, !1 = $word
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        GENERATOR_CREATE                                         
    5     2      > FE_RESET_R                                       $2      !0, ->9
          3    > > FE_FETCH_R                                               $2, !1, ->9
    6     4    >   INIT_FCALL                                               'strtoupper'
          5        SEND_VAR                                                 !1
          6        DO_ICALL                                         $3      
          7        YIELD                                                    $3
    5     8      > JMP                                                      ->3
          9    >   FE_FREE                                                  $2
    8    10      > GENERATOR_RETURN                                         

End of function uppercase

Function reverse:
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 = 161) Position 1 = -2
Branch analysis from position: 9
filename:       /in/hDRK5
function name:  reverse
number of ops:  11
compiled vars:  !0 = $in, !1 = $word
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
          1        GENERATOR_CREATE                                         
   12     2      > FE_RESET_R                                       $2      !0, ->9
          3    > > FE_FETCH_R                                               $2, !1, ->9
   13     4    >   INIT_FCALL                                               'strrev'
          5        SEND_VAR                                                 !1
          6        DO_ICALL                                         $3      
          7        YIELD                                                    $3
   12     8      > JMP                                                      ->3
          9    >   FE_FREE                                                  $2
   15    10      > GENERATOR_RETURN                                         

End of function reverse

Function each_println:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 7
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 7
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
filename:       /in/hDRK5
function name:  each_println
number of ops:  9
compiled vars:  !0 = $in, !1 = $line
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
   19     1      > FE_RESET_R                                       $2      !0, ->7
          2    > > FE_FETCH_R                                               $2, !1, ->7
   20     3    >   NOP                                                      
          4        FAST_CONCAT                                      ~3      !1, '%0A'
          5        ECHO                                                     ~3
   19     6      > JMP                                                      ->2
          7    >   FE_FREE                                                  $2
   22     8      > RETURN                                                   null

End of function each_println

Function allabove:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 21
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 21
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 21
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 21
filename:       /in/hDRK5
function name:  allAbove
number of ops:  23
compiled vars:  !0 = $in, !1 = $word
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   RECV                                             !0      
          1        GENERATOR_CREATE                                         
   26     2      > FE_RESET_R                                       $2      !0, ->21
          3    > > FE_FETCH_R                                               $2, !1, ->21
   27     4    >   INIT_FCALL                                               'strtoupper'
          5        SEND_VAR                                                 !1
          6        DO_ICALL                                         $3      
          7        INIT_ARRAY                                       ~4      $3, 'upper'
          8        INIT_FCALL                                               'strrev'
          9        SEND_VAR                                                 !1
         10        DO_ICALL                                         $5      
         11        ADD_ARRAY_ELEMENT                                ~4      $5, 'rev'
         12        INIT_FCALL                                               'strrev'
         13        INIT_FCALL                                               'strtoupper'
         14        SEND_VAR                                                 !1
         15        DO_ICALL                                         $6      
         16        SEND_VAR                                                 $6
         17        DO_ICALL                                         $7      
         18        ADD_ARRAY_ELEMENT                                ~4      $7, 'combined'
         19        YIELD                                                    ~4
   26    20      > JMP                                                      ->3
         21    >   FE_FREE                                                  $2
   29    22      > GENERATOR_RETURN                                         

End of function allabove

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.82 ms | 1406 KiB | 22 Q