3v4l.org

run code in 300+ PHP versions simultaneously
<?php class myData implements IteratorAggregate { public $property1 = "Public property one"; public $property2 = "Public property two"; public $property3 = "Public property three"; public function __construct() { $this->property4 = "last property"; } public function getIterator() { return new ArrayIterator($this); } } $obj = new myData; echo "foreach (new \$obj)\n"; foreach($obj as $key => $value) { var_dump($key, $value); echo "\n"; } echo "\nforeach (new ArrayIterator(\$obj))\n"; foreach(new ArrayIterator($obj) as $key => $value) { var_dump($key, $value); echo "\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 14
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 14
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 14
2 jumps found. (Code = 77) Position 1 = 20, Position 2 = 28
Branch analysis from position: 20
2 jumps found. (Code = 78) Position 1 = 21, Position 2 = 28
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
Branch analysis from position: 14
filename:       /in/i7QdK
function name:  (null)
number of ops:  30
compiled vars:  !0 = $obj, !1 = $value, !2 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   DECLARE_CLASS                                            'mydata'
   16     1        NEW                                              $3      'myData'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $3
   18     4        ECHO                                                     'foreach+%28new+%24obj%29%0A'
   20     5      > FE_RESET_R                                       $6      !0, ->14
          6    > > FE_FETCH_R                                       ~7      $6, !1, ->14
          7    >   ASSIGN                                                   !2, ~7
   21     8        INIT_FCALL                                               'var_dump'
          9        SEND_VAR                                                 !2
         10        SEND_VAR                                                 !1
         11        DO_ICALL                                                 
   22    12        ECHO                                                     '%0A'
   20    13      > JMP                                                      ->6
         14    >   FE_FREE                                                  $6
   25    15        ECHO                                                     '%0Aforeach+%28new+ArrayIterator%28%24obj%29%29%0A'
   27    16        NEW                                              $10     'ArrayIterator'
         17        SEND_VAR_EX                                              !0
         18        DO_FCALL                                      0          
         19      > FE_RESET_R                                       $12     $10, ->28
         20    > > FE_FETCH_R                                       ~13     $12, !1, ->28
         21    >   ASSIGN                                                   !2, ~13
   28    22        INIT_FCALL                                               'var_dump'
         23        SEND_VAR                                                 !2
         24        SEND_VAR                                                 !1
         25        DO_ICALL                                                 
   29    26        ECHO                                                     '%0A'
   27    27      > JMP                                                      ->20
         28    >   FE_FREE                                                  $12
   30    29      > RETURN                                                   1

Class myData:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/i7QdK
function name:  __construct
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   ASSIGN_OBJ                                               'property4'
          1        OP_DATA                                                  'last+property'
    9     2      > 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/i7QdK
function name:  getIterator
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   NEW                                              $0      'ArrayIterator'
          1        FETCH_THIS                                       $1      
          2        SEND_VAR_EX                                              $1
          3        DO_FCALL                                      0          
          4      > RETURN                                                   $0
   13     5*     > RETURN                                                   null

End of function getiterator

End of class myData.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
138 ms | 1450 KiB | 14 Q