3v4l.org

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

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

End of function __construct

Function getiterator:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 125) Position 1 = 3, Position 2 = 7
Branch analysis from position: 3
2 jumps found. (Code = 126) Position 1 = 4, Position 2 = 7
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 7
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 7
filename:       /in/rFo41
function name:  getIterator
number of ops:  9
compiled vars:  !0 = $value, !1 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   GENERATOR_CREATE                                         
   12     1        FETCH_OBJ_W                                      $2      'data'
          2      > FE_RESET_RW                                      $3      $2, ->7
          3    > > FE_FETCH_RW                                      ~4      $3, !0, ->7
          4    >   ASSIGN                                                   !1, ~4
   13     5        YIELD                                                    !0, !1
   12     6      > JMP                                                      ->3
          7    >   FE_FREE                                                  $3
   15     8      > GENERATOR_RETURN                                         

End of function getiterator

End of class DataContainer.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.81 ms | 1392 KiB | 15 Q