3v4l.org

run code in 300+ PHP versions simultaneously
<?php function emptyGenerator(): Generator { var_dump('Generator function started'); if (false) { yield 'some value'; } var_dump('Generator function finished'); } $generator = emptyGenerator(); var_dump('About to call $generator->valid()'); if ($generator->valid()) { var_dump('Generator is not empty, traversing'); foreach ($generator as $value) { var_dump('Generator yielded '.$value); } var_dump('Finished traversing generator'); } else { var_dump('Generator is empty'); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 24
Branch analysis from position: 9
2 jumps found. (Code = 77) Position 1 = 13, Position 2 = 19
Branch analysis from position: 13
2 jumps found. (Code = 78) Position 1 = 14, Position 2 = 19
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jni5Y
function name:  (null)
number of ops:  28
compiled vars:  !0 = $generator, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   INIT_FCALL                                               'emptygenerator'
          1        DO_FCALL                                      0  $2      
          2        ASSIGN                                                   !0, $2
   16     3        INIT_FCALL                                               'var_dump'
          4        SEND_VAL                                                 'About+to+call+%24generator-%3Evalid%28%29'
          5        DO_ICALL                                                 
   18     6        INIT_METHOD_CALL                                         !0, 'valid'
          7        DO_FCALL                                      0  $5      
          8      > JMPZ                                                     $5, ->24
   19     9    >   INIT_FCALL                                               'var_dump'
         10        SEND_VAL                                                 'Generator+is+not+empty%2C+traversing'
         11        DO_ICALL                                                 
   21    12      > FE_RESET_R                                       $7      !0, ->19
         13    > > FE_FETCH_R                                               $7, !1, ->19
   22    14    >   INIT_FCALL                                               'var_dump'
         15        CONCAT                                           ~8      'Generator+yielded+', !1
         16        SEND_VAL                                                 ~8
         17        DO_ICALL                                                 
   21    18      > JMP                                                      ->13
         19    >   FE_FREE                                                  $7
   25    20        INIT_FCALL                                               'var_dump'
         21        SEND_VAL                                                 'Finished+traversing+generator'
         22        DO_ICALL                                                 
   18    23      > JMP                                                      ->27
   27    24    >   INIT_FCALL                                               'var_dump'
         25        SEND_VAL                                                 'Generator+is+empty'
         26        DO_ICALL                                                 
   28    27    > > RETURN                                                   1

Function emptygenerator:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 6
Branch analysis from position: 5
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 6
filename:       /in/jni5Y
function name:  emptyGenerator
number of ops:  10
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   GENERATOR_CREATE                                         
    5     1        INIT_FCALL                                               'var_dump'
          2        SEND_VAL                                                 'Generator+function+started'
          3        DO_ICALL                                                 
    7     4      > JMPZ                                                     <false>, ->6
    8     5    >   YIELD                                                    'some+value'
   11     6    >   INIT_FCALL                                               'var_dump'
          7        SEND_VAL                                                 'Generator+function+finished'
          8        DO_ICALL                                                 
   12     9      > GENERATOR_RETURN                                         

End of function emptygenerator

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
138.97 ms | 1005 KiB | 15 Q