3v4l.org

run code in 500+ 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); } } class myIterator implements Iterator { private $position = 0; private $array = array('one', 'two', 'three'); function rewind() { $this->position = 0; } function current() { return $this->array[$this->position]; } function key() { return $this->position; } function next() { ++$this->position; } function valid() { return isset($this->array[$this->position]); } } $renderFunction = function($iterator) { foreach($iterator as $key => $value) { echo "$key: $value\n"; foreach($iterator as $key => $value) { echo " $key: $value\n"; } } }; echo "-----IteratorAggregate-----\n"; $renderFunction(new myData); echo "\n-----Iterator-----\n"; $renderFunction(new myIterator);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JHDNQ
function name:  (null)
number of ops:  17
compiled vars:  !0 = $renderFunction
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    2     0  E >   DECLARE_CLASS                                                'mydata'
   19     1        DECLARE_CLASS                                                'myiterator'
   50     2        DECLARE_LAMBDA_FUNCTION                              ~1      [0]
          3        ASSIGN                                                       !0, ~1
   58     4        ECHO                                                         '-----IteratorAggregate-----%0A'
   59     5        INIT_DYNAMIC_CALL                                            !0
          6        NEW                                                  $3      'myData'
          7        DO_FCALL                                          0          
          8        SEND_VAR_NO_REF_EX                                           $3
          9        DO_FCALL                                          0          
   61    10        ECHO                                                         '%0A-----Iterator-----%0A'
   62    11        INIT_DYNAMIC_CALL                                            !0
         12        NEW                                                  $6      'myIterator'
         13        DO_FCALL                                          0          
         14        SEND_VAR_NO_REF_EX                                           $6
         15        DO_FCALL                                          0          
         16      > RETURN                                                       1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 21
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 21
Branch analysis from position: 3
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 19
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 19
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 19
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
filename:       /in/JHDNQ
function name:  {closure:/in/JHDNQ:50}
number of ops:  23
compiled vars:  !0 = $iterator, !1 = $value, !2 = $key
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   50     0  E >   RECV                                                 !0      
   51     1      > FE_RESET_R                                           $3      !0, ->21
          2    > > FE_FETCH_R                                           ~4      $3, !1, ->21
          3    >   ASSIGN                                                       !2, ~4
   52     4        ROPE_INIT                                         4  ~7      !2
          5        ROPE_ADD                                          1  ~7      ~7, '%3A+'
          6        ROPE_ADD                                          2  ~7      ~7, !1
          7        ROPE_END                                          3  ~6      ~7, '%0A'
          8        ECHO                                                         ~6
   53     9      > FE_RESET_R                                           $9      !0, ->19
         10    > > FE_FETCH_R                                           ~10     $9, !1, ->19
         11    >   ASSIGN                                                       !2, ~10
   54    12        ROPE_INIT                                         5  ~13     '++++'
         13        ROPE_ADD                                          1  ~13     ~13, !2
         14        ROPE_ADD                                          2  ~13     ~13, '%3A+'
         15        ROPE_ADD                                          3  ~13     ~13, !1
         16        ROPE_END                                          4  ~12     ~13, '%0A'
         17        ECHO                                                         ~12
   53    18      > JMP                                                          ->10
         19    >   FE_FREE                                                      $9
   51    20      > JMP                                                          ->2
         21    >   FE_FREE                                                      $3
   57    22      > RETURN                                                       null

End of Dynamic Function 0

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

End of function getiterator

End of class myData.

Class myIterator:
Function rewind:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JHDNQ
function name:  rewind
number of ops:  3
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   26     0  E >   ASSIGN_OBJ                                                   'position'
          1        OP_DATA                                                      0
   27     2      > RETURN                                                       null

End of function rewind

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

End of function current

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

End of function key

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

End of function next

Function valid:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JHDNQ
function name:  valid
number of ops:  5
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   46     0  E >   FETCH_OBJ_R                                          ~1      'position'
          1        FETCH_OBJ_IS                                         ~0      'array'
          2        ISSET_ISEMPTY_DIM_OBJ                             0  ~2      ~0, ~1
          3      > RETURN                                                       ~2
   47     4*     > RETURN                                                       null

End of function valid

End of class myIterator.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
223.27 ms | 3148 KiB | 13 Q