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 = ['b' => ['4', '5', '6'], 'c' => ['1', '2', '3']]; public function generator() { foreach (self::$a as $k => $v) { yield $this->getType($k); } } public function getType(){ foreach (self::$a[$type] as $t) { yield $t; } self::$a[$type] = []; } } $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/TN2dU
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                                                 
   26     8        NEW                                              $5      'Foo'
          9        DO_FCALL                                      0          
         10        ASSIGN                                                   !0, $5
   27    11        INIT_METHOD_CALL                                         !0, 'generator'
         12        DO_FCALL                                      0  $8      
         13        ASSIGN                                                   !1, $8
   28    14        INIT_METHOD_CALL                                         !1, 'valid'
         15        DO_FCALL                                      0  $10     
         16      > JMPZ                                                     $10, ->23
   29    17    > > FE_RESET_R                                       $11     !1, ->21
         18    > > FE_FETCH_R                                               $11, !2, ->21
   30    19    >   ECHO                                                     !2
   29    20      > JMP                                                      ->18
         21    >   FE_FREE                                                  $11
         22      > JMP                                                      ->24
   33    23    >   ECHO                                                     'Nothing'
   36    24    >   INIT_METHOD_CALL                                         !0, 'generator'
         25        DO_FCALL                                      0  $12     
         26        ASSIGN                                                   !1, $12
   37    27        INIT_METHOD_CALL                                         !1, 'valid'
         28        DO_FCALL                                      0  $14     
         29      > JMPZ                                                     $14, ->36
   38    30    > > FE_RESET_R                                       $15     !1, ->34
         31    > > FE_FETCH_R                                               $15, !2, ->34
   39    32    >   ECHO                                                     !2
   38    33      > JMP                                                      ->31
         34    >   FE_FREE                                                  $15
         35      > JMP                                                      ->37
   42    36    >   ECHO                                                     'Nothing'
   43    37    > > RETURN                                                   1

Class Foo:
Function generator:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 10
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 10
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 10
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 10
filename:       /in/TN2dU
function name:  generator
number of ops:  12
compiled vars:  !0 = $v, !1 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   GENERATOR_CREATE                                         
   13     1        FETCH_STATIC_PROP_R          unknown             ~2      'a'
          2      > FE_RESET_R                                       $3      ~2, ->10
          3    > > FE_FETCH_R                                       ~4      $3, !0, ->10
          4    >   ASSIGN                                                   !1, ~4
   14     5        INIT_METHOD_CALL                                         'getType'
          6        SEND_VAR_EX                                              !1
          7        DO_FCALL                                      0  $6      
          8        YIELD                                                    $6
   13     9      > JMP                                                      ->3
         10    >   FE_FREE                                                  $3
   16    11      > GENERATOR_RETURN                                         

End of function generator

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

End of function gettype

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
166.42 ms | 1404 KiB | 15 Q