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() { 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/EdknC
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                                                 
   25     8        NEW                                              $5      'Foo'
          9        DO_FCALL                                      0          
         10        ASSIGN                                                   !0, $5
   26    11        INIT_METHOD_CALL                                         !0, 'generator'
         12        DO_FCALL                                      0  $8      
         13        ASSIGN                                                   !1, $8
   27    14        INIT_METHOD_CALL                                         !1, 'valid'
         15        DO_FCALL                                      0  $10     
         16      > JMPZ                                                     $10, ->23
   28    17    > > FE_RESET_R                                       $11     !1, ->21
         18    > > FE_FETCH_R                                               $11, !2, ->21
   29    19    >   ECHO                                                     !2
   28    20      > JMP                                                      ->18
         21    >   FE_FREE                                                  $11
         22      > JMP                                                      ->24
   32    23    >   ECHO                                                     'Nothing'
   35    24    >   INIT_METHOD_CALL                                         !0, 'generator'
         25        DO_FCALL                                      0  $12     
         26        ASSIGN                                                   !1, $12
   36    27        INIT_METHOD_CALL                                         !1, 'valid'
         28        DO_FCALL                                      0  $14     
         29      > JMPZ                                                     $14, ->36
   37    30    > > FE_RESET_R                                       $15     !1, ->34
         31    > > FE_FETCH_R                                               $15, !2, ->34
   38    32    >   ECHO                                                     !2
   37    33      > JMP                                                      ->31
         34    >   FE_FREE                                                  $15
         35      > JMP                                                      ->37
   41    36    >   ECHO                                                     'Nothing'
   42    37    > > RETURN                                                   1

Class Foo:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EdknC
function name:  __construct
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   INIT_FCALL                                               'range'
          1        SEND_VAL                                                 'A'
          2        SEND_VAL                                                 'Z'
          3        DO_ICALL                                         $1      
          4        ASSIGN_STATIC_PROP                                       'a'
          5        OP_DATA                                                  $1
   14     6      > 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/EdknC
function name:  generator
number of ops:  16
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   GENERATOR_CREATE                                         
   18     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
   19     7      > JMP                                                      ->13
   20     8    >   INIT_FCALL                                               'array_pop'
          9        FETCH_STATIC_PROP_W          unknown             $3      'a'
         10        SEND_REF                                                 $3
         11        DO_ICALL                                         $4      
         12        YIELD                                                    $4
   19    13    >   FETCH_STATIC_PROP_R          unknown             ~6      'a'
         14      > JMPNZ                                                    ~6, ->8
   22    15    > > GENERATOR_RETURN                                         

End of function generator

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
174.35 ms | 1400 KiB | 21 Q