3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ObjectKeyIterator extends IteratorIterator { public function __construct(\Traversable $iterator) { parent::__construct($iterator); } public function key() { $key = parent::key(); return (object)array('key' => $key); } } /*foreach(new ObjectKeyIterator(new ArrayObject(array('test' => 'foo', 2,4, 'bo' => 24,2))) as $key => $value) { var_dump($key, $value); }*/ $iterator = new ObjectKeyIterator(new ArrayObject(array('test' => 'foo', 2,4, 'bo' => 24,2))); $iterator->rewind(); while ($iterator->valid()) { $key = $iterator->key(); if(is_int($key) || is_string($key)) { $array[$key] = $iterator->current(); } else { $array[] = $iterator->current(); } $iterator->next(); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
2 jumps found. (Code = 44) Position 1 = 32, Position 2 = 10
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
2 jumps found. (Code = 47) Position 1 = 15, Position 2 = 17
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 23
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
2 jumps found. (Code = 44) Position 1 = 32, Position 2 = 10
Branch analysis from position: 32
Branch analysis from position: 10
Branch analysis from position: 23
2 jumps found. (Code = 44) Position 1 = 32, Position 2 = 10
Branch analysis from position: 32
Branch analysis from position: 10
Branch analysis from position: 17
filename:       /in/Ir0KA
function name:  (null)
number of ops:  33
compiled vars:  !0 = $iterator, !1 = $key, !2 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   NEW                                              $3      'ObjectKeyIterator'
          1        NEW                                              $4      'ArrayObject'
          2        SEND_VAL_EX                                              <array>
          3        DO_FCALL                                      0          
          4        SEND_VAR_NO_REF_EX                                       $4
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !0, $3
   21     7        INIT_METHOD_CALL                                         !0, 'rewind'
          8        DO_FCALL                                      0          
   23     9      > JMP                                                      ->29
   24    10    >   INIT_METHOD_CALL                                         !0, 'key'
         11        DO_FCALL                                      0  $9      
         12        ASSIGN                                                   !1, $9
   25    13        TYPE_CHECK                                   16  ~11     !1
         14      > JMPNZ_EX                                         ~11     ~11, ->17
         15    >   TYPE_CHECK                                   64  ~12     !1
         16        BOOL                                             ~11     ~12
         17    > > JMPZ                                                     ~11, ->23
   26    18    >   INIT_METHOD_CALL                                         !0, 'current'
         19        DO_FCALL                                      0  $14     
         20        ASSIGN_DIM                                               !2, !1
         21        OP_DATA                                                  $14
         22      > JMP                                                      ->27
   28    23    >   INIT_METHOD_CALL                                         !0, 'current'
         24        DO_FCALL                                      0  $16     
         25        ASSIGN_DIM                                               !2
         26        OP_DATA                                                  $16
   30    27    >   INIT_METHOD_CALL                                         !0, 'next'
         28        DO_FCALL                                      0          
   23    29    >   INIT_METHOD_CALL                                         !0, 'valid'
         30        DO_FCALL                                      0  $18     
         31      > JMPNZ                                                    $18, ->10
   31    32    > > RETURN                                                   1

Class ObjectKeyIterator:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Ir0KA
function name:  __construct
number of ops:  5
compiled vars:  !0 = $iterator
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
    6     1        INIT_STATIC_METHOD_CALL                                  
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
    7     4      > RETURN                                                   null

End of function __construct

Function key:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Ir0KA
function name:  key
number of ops:  7
compiled vars:  !0 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   INIT_STATIC_METHOD_CALL                                  'key'
          1        DO_FCALL                                      0  $1      
          2        ASSIGN                                                   !0, $1
   13     3        INIT_ARRAY                                       ~3      !0, 'key'
          4        CAST                                          8  ~4      ~3
          5      > RETURN                                                   ~4
   14     6*     > RETURN                                                   null

End of function key

End of class ObjectKeyIterator.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.08 ms | 1399 KiB | 13 Q