3v4l.org

run code in 300+ PHP versions simultaneously
<?php class DataContainer implements IteratorAggregate { protected $data; public function __construct(array $data) { $this->data = $data; } public function getIterator() { foreach (array_keys($this->data) as $key) { yield $key => $data[$key]; } } } $dataContainer = new DataContainer([1, 2, 3]); foreach ($dataContainer as $value) { $value *= -1; } var_dump($dataContainer);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 9
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 9
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
filename:       /in/EEii4
function name:  (null)
number of ops:  14
compiled vars:  !0 = $dataContainer, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'datacontainer'
   17     1        NEW                                              $2      'DataContainer'
          2        SEND_VAL_EX                                              <array>
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $2
   18     5      > FE_RESET_R                                       $5      !0, ->9
          6    > > FE_FETCH_R                                               $5, !1, ->9
   19     7    >   ASSIGN_OP                                     3          !1, -1
   18     8      > JMP                                                      ->6
          9    >   FE_FREE                                                  $5
   21    10        INIT_FCALL                                               'var_dump'
         11        SEND_VAR                                                 !0
         12        DO_ICALL                                                 
         13      > RETURN                                                   1

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

End of function __construct

Function getiterator:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 10
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 10
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 10
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 10
filename:       /in/EEii4
function name:  getIterator
number of ops:  12
compiled vars:  !0 = $key, !1 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   GENERATOR_CREATE                                         
   11     1        INIT_FCALL                                               'array_keys'
          2        FETCH_OBJ_R                                      ~2      'data'
          3        SEND_VAL                                                 ~2
          4        DO_ICALL                                         $3      
          5      > FE_RESET_R                                       $4      $3, ->10
          6    > > FE_FETCH_R                                               $4, !0, ->10
   12     7    >   FETCH_DIM_R                                      ~5      !1, !0
          8        YIELD                                                    ~5, !0
   11     9      > JMP                                                      ->6
         10    >   FE_FREE                                                  $4
   14    11      > GENERATOR_RETURN                                         

End of function getiterator

End of class DataContainer.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.64 ms | 1400 KiB | 17 Q