3v4l.org

run code in 300+ PHP versions simultaneously
<?php ini_set('error_reporting', -1); ini_set('display_errors', 'on'); class Foo { private static $a = []; public function __construct() { for($i=0; $i < 100; $i++) { self::$a = self::$a + range('A', 'Z'); } } public function generator() { foreach (self::$a as $i) { yield $i; } self::$a = []; } } $foo = new Foo; $generator = $foo->generator(); if ($generator->valid()) { foreach($generator as $i) { echo $i; } } else { echo 'Nothing'; } $generator = $foo->generator(); if ($generator->valid()) { foreach($generator as $i) { echo $i; } } else { echo 'Nothing'; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 23
Branch analysis from position: 17
2 jumps found. (Code = 77) Position 1 = 18, Position 2 = 21
Branch analysis from position: 18
2 jumps found. (Code = 78) Position 1 = 19, Position 2 = 21
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 36
Branch analysis from position: 30
2 jumps found. (Code = 77) Position 1 = 31, Position 2 = 34
Branch analysis from position: 31
2 jumps found. (Code = 78) Position 1 = 32, Position 2 = 34
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
Branch analysis from position: 34
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 34
Branch analysis from position: 36
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
Branch analysis from position: 23
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 36
Branch analysis from position: 30
Branch analysis from position: 36
filename:       /in/cpHgp
function name:  (null)
number of ops:  38
compiled vars:  !0 = $foo, !1 = $generator, !2 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'ini_set'
          1        SEND_VAL                                                 'error_reporting'
          2        SEND_VAL                                                 -1
          3        DO_ICALL                                                 
    4     4        INIT_FCALL                                               'ini_set'
          5        SEND_VAL                                                 'display_errors'
          6        SEND_VAL                                                 'on'
          7        DO_ICALL                                                 
   27     8        NEW                                              $5      'Foo'
          9        DO_FCALL                                      0          
         10        ASSIGN                                                   !0, $5
   28    11        INIT_METHOD_CALL                                         !0, 'generator'
         12        DO_FCALL                                      0  $8      
         13        ASSIGN                                                   !1, $8
   29    14        INIT_METHOD_CALL                                         !1, 'valid'
         15        DO_FCALL                                      0  $10     
         16      > JMPZ                                                     $10, ->23
   30    17    > > FE_RESET_R                                       $11     !1, ->21
         18    > > FE_FETCH_R                                               $11, !2, ->21
   31    19    >   ECHO                                                     !2
   30    20      > JMP                                                      ->18
         21    >   FE_FREE                                                  $11
         22      > JMP                                                      ->24
   34    23    >   ECHO                                                     'Nothing'
   37    24    >   INIT_METHOD_CALL                                         !0, 'generator'
         25        DO_FCALL                                      0  $12     
         26        ASSIGN                                                   !1, $12
   38    27        INIT_METHOD_CALL                                         !1, 'valid'
         28        DO_FCALL                                      0  $14     
         29      > JMPZ                                                     $14, ->36
   39    30    > > FE_RESET_R                                       $15     !1, ->34
         31    > > FE_FETCH_R                                               $15, !2, ->34
   40    32    >   ECHO                                                     !2
   39    33      > JMP                                                      ->31
         34    >   FE_FREE                                                  $15
         35      > JMP                                                      ->37
   43    36    >   ECHO                                                     'Nothing'
   44    37    > > RETURN                                                   1

Class Foo:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
2 jumps found. (Code = 44) Position 1 = 13, Position 2 = 2
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 2
2 jumps found. (Code = 44) Position 1 = 13, Position 2 = 2
Branch analysis from position: 13
Branch analysis from position: 2
filename:       /in/cpHgp
function name:  __construct
number of ops:  14
compiled vars:  !0 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   ASSIGN                                                   !0, 0
          1      > JMP                                                      ->11
   14     2    >   FETCH_STATIC_PROP_R          unknown             ~3      'a'
          3        INIT_FCALL                                               'range'
          4        SEND_VAL                                                 'A'
          5        SEND_VAL                                                 'Z'
          6        DO_ICALL                                         $4      
          7        ADD                                              ~5      ~3, $4
          8        ASSIGN_STATIC_PROP                                       'a'
          9        OP_DATA                                                  ~5
   13    10        PRE_INC                                                  !0
         11    >   IS_SMALLER                                               !0, 100
         12      > JMPNZ                                                    ~7, ->2
   16    13    > > RETURN                                                   null

End of function __construct

Function generator:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 6
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 6
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 6
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 6
filename:       /in/cpHgp
function name:  generator
number of ops:  10
compiled vars:  !0 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   GENERATOR_CREATE                                         
   20     1        FETCH_STATIC_PROP_R          unknown             ~1      'a'
          2      > FE_RESET_R                                       $2      ~1, ->6
          3    > > FE_FETCH_R                                               $2, !0, ->6
   21     4    >   YIELD                                                    !0
   20     5      > JMP                                                      ->3
          6    >   FE_FREE                                                  $2
   23     7        ASSIGN_STATIC_PROP                                       'a'
          8        OP_DATA                                                  <array>
   24     9      > GENERATOR_RETURN                                         

End of function generator

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
212.73 ms | 1404 KiB | 17 Q