3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo implements Iterator { public function rewind(){ echo "rewind\n"; } private $c = 0; public function valid(){ return $this->c++ < 5; } public function next(){} public function key(){ return $this->c; } public function current(){ return $this->c; } } $gen = (function(){ $foo = new Foo(); $foo->rewind(); $foo->valid(); yield $foo->key() => $foo->current(); $foo->next(); $foo->valid(); yield $foo->key() => $foo->current(); yield from $foo; })(); foreach($gen as $k => $v){ echo $k . " => " . $v . "\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 13
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 13
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
filename:       /in/8k4me
function name:  (null)
number of ops:  15
compiled vars:  !0 = $gen, !1 = $v, !2 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'foo'
   20     1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F8k4me%3A20%241'
   29     2        INIT_DYNAMIC_CALL                                        ~3
          3        DO_FCALL                                      0  $4      
   20     4        ASSIGN                                                   !0, $4
   32     5      > FE_RESET_R                                       $6      !0, ->13
          6    > > FE_FETCH_R                                       ~7      $6, !1, ->13
          7    >   ASSIGN                                                   !2, ~7
   33     8        CONCAT                                           ~9      !2, '+%3D%3E+'
          9        CONCAT                                           ~10     ~9, !1
         10        CONCAT                                           ~11     ~10, '%0A'
         11        ECHO                                                     ~11
   32    12      > JMP                                                      ->6
         13    >   FE_FREE                                                  $6
   34    14      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2F8k4me%3A20%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/8k4me
function name:  {closure}
number of ops:  25
compiled vars:  !0 = $foo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   GENERATOR_CREATE                                         
   21     1        NEW                                              $1      'Foo'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $1
   22     4        INIT_METHOD_CALL                                         !0, 'rewind'
          5        DO_FCALL                                      0          
   23     6        INIT_METHOD_CALL                                         !0, 'valid'
          7        DO_FCALL                                      0          
   24     8        INIT_METHOD_CALL                                         !0, 'key'
          9        DO_FCALL                                      0  $6      
         10        INIT_METHOD_CALL                                         !0, 'current'
         11        DO_FCALL                                      0  $7      
         12        YIELD                                                    $7, $6
   25    13        INIT_METHOD_CALL                                         !0, 'next'
         14        DO_FCALL                                      0          
   26    15        INIT_METHOD_CALL                                         !0, 'valid'
         16        DO_FCALL                                      0          
   27    17        INIT_METHOD_CALL                                         !0, 'key'
         18        DO_FCALL                                      0  $11     
         19        INIT_METHOD_CALL                                         !0, 'current'
         20        DO_FCALL                                      0  $12     
         21        YIELD                                                    $12, $11
   28    22        YIELD_FROM                                       ~14     !0
         23        FREE                                                     ~14
   29    24      > GENERATOR_RETURN                                         

End of function %00%7Bclosure%7D%2Fin%2F8k4me%3A20%241

Class Foo:
Function rewind:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8k4me
function name:  rewind
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   ECHO                                                     'rewind%0A'
    7     1      > RETURN                                                   null

End of function rewind

Function valid:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8k4me
function name:  valid
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   POST_INC_OBJ                                     ~0      'c'
          1        IS_SMALLER                                       ~1      ~0, 5
          2      > RETURN                                                   ~1
   12     3*     > RETURN                                                   null

End of function valid

Function next:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8k4me
function name:  next
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E > > RETURN                                                   null

End of function next

Function key:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8k4me
function name:  key
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   FETCH_OBJ_R                                      ~0      'c'
          1      > RETURN                                                   ~0
          2*     > RETURN                                                   null

End of function key

Function current:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8k4me
function name:  current
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   FETCH_OBJ_R                                      ~0      'c'
          1      > RETURN                                                   ~0
          2*     > RETURN                                                   null

End of function current

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
169.93 ms | 1399 KiB | 13 Q