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 = array_merge(self::$a, range('A', 'Z')); } } public function generator() { self::$a = array_reverse(self::$a); while(self::$a) { yield array_pop(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/XAbUS
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 = 14
Branch analysis from position: 14
2 jumps found. (Code = 44) Position 1 = 16, Position 2 = 2
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 2
2 jumps found. (Code = 44) Position 1 = 16, Position 2 = 2
Branch analysis from position: 16
Branch analysis from position: 2
filename:       /in/XAbUS
function name:  __construct
number of ops:  17
compiled vars:  !0 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   ASSIGN                                                   !0, 0
          1      > JMP                                                      ->14
   14     2    >   INIT_FCALL                                               'array_merge'
          3        FETCH_STATIC_PROP_R          unknown             ~3      'a'
          4        SEND_VAL                                                 ~3
          5        INIT_FCALL                                               'range'
          6        SEND_VAL                                                 'A'
          7        SEND_VAL                                                 'Z'
          8        DO_ICALL                                         $4      
          9        SEND_VAR                                                 $4
         10        DO_ICALL                                         $5      
         11        ASSIGN_STATIC_PROP                                       'a'
         12        OP_DATA                                                  $5
   13    13        PRE_INC                                                  !0
         14    >   IS_SMALLER                                               !0, 100
         15      > JMPNZ                                                    ~7, ->2
   16    16    > > RETURN                                                   null

End of function __construct

Function generator:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
2 jumps found. (Code = 44) Position 1 = 15, Position 2 = 8
Branch analysis from position: 15
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 8
2 jumps found. (Code = 44) Position 1 = 15, Position 2 = 8
Branch analysis from position: 15
Branch analysis from position: 8
filename:       /in/XAbUS
function name:  generator
number of ops:  16
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   GENERATOR_CREATE                                         
   20     1        INIT_FCALL                                               'array_reverse'
          2        FETCH_STATIC_PROP_R          unknown             ~1      'a'
          3        SEND_VAL                                                 ~1
          4        DO_ICALL                                         $2      
          5        ASSIGN_STATIC_PROP                                       'a'
          6        OP_DATA                                                  $2
   21     7      > JMP                                                      ->13
   22     8    >   INIT_FCALL                                               'array_pop'
          9        FETCH_STATIC_PROP_W          unknown             $3      'a'
         10        SEND_REF                                                 $3
         11        DO_ICALL                                         $4      
         12        YIELD                                                    $4
   21    13    >   FETCH_STATIC_PROP_R          unknown             ~6      'a'
         14      > JMPNZ                                                    ~6, ->8
   24    15    > > GENERATOR_RETURN                                         

End of function generator

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.55 ms | 1404 KiB | 23 Q