3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A implements IteratorAggregate { public $b; public function __construct(B $b) { $this->b = $b; } public function getIterator() { return $b; } } class B implements IteratorAggregate { public function getIterator() { for ($i = 0; $i < 5; $i++) { yield $i => $i; } } } $a = new A(new B); foreach ($a as $key => $value) { var_dump($key, $value); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 16
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 16
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
filename:       /in/Z88RT
function name:  (null)
number of ops:  18
compiled vars:  !0 = $a, !1 = $value, !2 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'a'
   13     1        DECLARE_CLASS                                            'b'
   21     2        NEW                                              $3      'A'
          3        NEW                                              $4      'B'
          4        DO_FCALL                                      0          
          5        SEND_VAR_NO_REF_EX                                       $4
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !0, $3
   23     8      > FE_RESET_R                                       $8      !0, ->16
          9    > > FE_FETCH_R                                       ~9      $8, !1, ->16
         10    >   ASSIGN                                                   !2, ~9
   24    11        INIT_FCALL                                               'var_dump'
         12        SEND_VAR                                                 !2
         13        SEND_VAR                                                 !1
         14        DO_ICALL                                                 
   23    15      > JMP                                                      ->9
         16    >   FE_FREE                                                  $8
   25    17      > RETURN                                                   1

Class A:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Z88RT
function name:  __construct
number of ops:  4
compiled vars:  !0 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    6     1        ASSIGN_OBJ                                               'b'
          2        OP_DATA                                                  !0
    7     3      > RETURN                                                   null

End of function __construct

Function getiterator:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Z88RT
function name:  getIterator
number of ops:  2
compiled vars:  !0 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E > > RETURN                                                   !0
   10     1*     > RETURN                                                   null

End of function getiterator

End of class A.

Class B:
Function getiterator:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
2 jumps found. (Code = 44) Position 1 = 7, Position 2 = 3
Branch analysis from position: 7
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 3
2 jumps found. (Code = 44) Position 1 = 7, Position 2 = 3
Branch analysis from position: 7
Branch analysis from position: 3
filename:       /in/Z88RT
function name:  getIterator
number of ops:  8
compiled vars:  !0 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   GENERATOR_CREATE                                         
   15     1        ASSIGN                                                   !0, 0
          2      > JMP                                                      ->5
   16     3    >   YIELD                                                    !0, !0
   15     4        PRE_INC                                                  !0
          5    >   IS_SMALLER                                               !0, 5
          6      > JMPNZ                                                    ~4, ->3
   18     7    > > GENERATOR_RETURN                                         

End of function getiterator

End of class B.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.45 ms | 1392 KiB | 15 Q