3v4l.org

run code in 300+ PHP versions simultaneously
<?php class values implements IteratorAggregate { protected $iterator; public function __construct($objOrArr) { if(is_array($objOrArr)) { $this->iterator = new ArrayObject($objOrArr); } else if(is_object($objOrArr)) { $this->iterator = new ArrayObject(get_object_vars($objOrArr)); } else { throw new Exception('$objOrArray is neither an array or an object'); } } public function getIterator() { return $this->iterator; } } $values = new values(new DateTime()); foreach($values as $k => $v) { var_dump($k, $v); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 15
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 15
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
filename:       /in/O2SR4
function name:  (null)
number of ops:  17
compiled vars:  !0 = $values, !1 = $v, !2 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'values'
   23     1        NEW                                              $3      'values'
          2        NEW                                              $4      'DateTime'
          3        DO_FCALL                                      0          
          4        SEND_VAR_NO_REF_EX                                       $4
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !0, $3
   25     7      > FE_RESET_R                                       $8      !0, ->15
          8    > > FE_FETCH_R                                       ~9      $8, !1, ->15
          9    >   ASSIGN                                                   !2, ~9
   26    10        INIT_FCALL                                               'var_dump'
         11        SEND_VAR                                                 !2
         12        SEND_VAR                                                 !1
         13        DO_ICALL                                                 
   25    14      > JMP                                                      ->8
         15    >   FE_FREE                                                  $8
   27    16      > RETURN                                                   1

Class values:
Function __construct:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 9
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 20
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
Branch analysis from position: 20
1 jumps found. (Code = 108) Position 1 = -2
filename:       /in/O2SR4
function name:  __construct
number of ops:  25
compiled vars:  !0 = $objOrArr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
    9     1        TYPE_CHECK                                  128          !0
          2      > JMPZ                                                     ~1, ->9
   10     3    >   NEW                                              $3      'ArrayObject'
          4        SEND_VAR_EX                                              !0
          5        DO_FCALL                                      0          
          6        ASSIGN_OBJ                                               'iterator'
          7        OP_DATA                                                  $3
          8      > JMP                                                      ->24
   11     9    >   TYPE_CHECK                                  256          !0
         10      > JMPZ                                                     ~5, ->20
   12    11    >   NEW                                              $7      'ArrayObject'
         12        INIT_FCALL                                               'get_object_vars'
         13        SEND_VAR                                                 !0
         14        DO_ICALL                                         $8      
         15        SEND_VAR_NO_REF_EX                                       $8
         16        DO_FCALL                                      0          
         17        ASSIGN_OBJ                                               'iterator'
         18        OP_DATA                                                  $7
         19      > JMP                                                      ->24
   14    20    >   NEW                                              $10     'Exception'
         21        SEND_VAL_EX                                              '%24objOrArray+is+neither+an+array+or+an+object'
         22        DO_FCALL                                      0          
         23      > THROW                                         0          $10
   16    24    > > 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/O2SR4
function name:  getIterator
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   FETCH_OBJ_R                                      ~0      'iterator'
          1      > RETURN                                                   ~0
   20     2*     > RETURN                                                   null

End of function getiterator

End of class values.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.08 ms | 1405 KiB | 17 Q