3v4l.org

run code in 300+ PHP versions simultaneously
<?php function gen1() { $x = yield 1; $y = yield 2; var_dump("==="); var_dump($x + $y); var_dump("==="); yield 3; } function wat($iter) { var_dump($iter->valid()); } function yf($iter) { $x = yield from $iter; var_dump('== ' . $x . ' =='); } // wat(gen1()); // wat([4, 5, 6]); // $g = yf([4, 5, 6]); $g = yf(gen1()); var_dump($g->current()); $g->send(10); var_dump($g->current()); $g->next(); var_dump($g->current()); $g->next(); var_dump($g->current());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/00Mad
function name:  (null)
number of ops:  34
compiled vars:  !0 = $g
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   INIT_FCALL                                               'yf'
          1        INIT_FCALL                                               'gen1'
          2        DO_FCALL                                      0  $1      
          3        SEND_VAR                                                 $1
          4        DO_FCALL                                      0  $2      
          5        ASSIGN                                                   !0, $2
   25     6        INIT_FCALL                                               'var_dump'
          7        INIT_METHOD_CALL                                         !0, 'current'
          8        DO_FCALL                                      0  $4      
          9        SEND_VAR                                                 $4
         10        DO_ICALL                                                 
   26    11        INIT_METHOD_CALL                                         !0, 'send'
         12        SEND_VAL_EX                                              10
         13        DO_FCALL                                      0          
   27    14        INIT_FCALL                                               'var_dump'
         15        INIT_METHOD_CALL                                         !0, 'current'
         16        DO_FCALL                                      0  $7      
         17        SEND_VAR                                                 $7
         18        DO_ICALL                                                 
   28    19        INIT_METHOD_CALL                                         !0, 'next'
         20        DO_FCALL                                      0          
   29    21        INIT_FCALL                                               'var_dump'
         22        INIT_METHOD_CALL                                         !0, 'current'
         23        DO_FCALL                                      0  $10     
         24        SEND_VAR                                                 $10
         25        DO_ICALL                                                 
   30    26        INIT_METHOD_CALL                                         !0, 'next'
         27        DO_FCALL                                      0          
   31    28        INIT_FCALL                                               'var_dump'
         29        INIT_METHOD_CALL                                         !0, 'current'
         30        DO_FCALL                                      0  $13     
         31        SEND_VAR                                                 $13
         32        DO_ICALL                                                 
         33      > RETURN                                                   1

Function gen1:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/00Mad
function name:  gen1
number of ops:  17
compiled vars:  !0 = $x, !1 = $y
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   GENERATOR_CREATE                                         
    4     1        YIELD                                            $2      1
          2        ASSIGN                                                   !0, $2
    5     3        YIELD                                            $4      2
          4        ASSIGN                                                   !1, $4
    6     5        INIT_FCALL                                               'var_dump'
          6        SEND_VAL                                                 '%3D%3D%3D'
          7        DO_ICALL                                                 
    7     8        INIT_FCALL                                               'var_dump'
          9        ADD                                              ~7      !0, !1
         10        SEND_VAL                                                 ~7
         11        DO_ICALL                                                 
    8    12        INIT_FCALL                                               'var_dump'
         13        SEND_VAL                                                 '%3D%3D%3D'
         14        DO_ICALL                                                 
    9    15        YIELD                                                    3
   10    16      > GENERATOR_RETURN                                         

End of function gen1

Function wat:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/00Mad
function name:  wat
number of ops:  7
compiled vars:  !0 = $iter
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
   13     1        INIT_FCALL                                               'var_dump'
          2        INIT_METHOD_CALL                                         !0, 'valid'
          3        DO_FCALL                                      0  $1      
          4        SEND_VAR                                                 $1
          5        DO_ICALL                                                 
   14     6      > RETURN                                                   null

End of function wat

Function yf:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/00Mad
function name:  yf
number of ops:  10
compiled vars:  !0 = $iter, !1 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
          1        GENERATOR_CREATE                                         
   17     2        YIELD_FROM                                       ~2      !0
          3        ASSIGN                                                   !1, ~2
   18     4        INIT_FCALL                                               'var_dump'
          5        CONCAT                                           ~4      '%3D%3D+', !1
          6        CONCAT                                           ~5      ~4, '+%3D%3D'
          7        SEND_VAL                                                 ~5
          8        DO_ICALL                                                 
   19     9      > GENERATOR_RETURN                                         

End of function yf

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
163.94 ms | 1403 KiB | 17 Q