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(); $value = $iterator->current(); var_dump($key, $value); $iterator->next(); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
2 jumps found. (Code = 44) Position 1 = 25, Position 2 = 10
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
2 jumps found. (Code = 44) Position 1 = 25, Position 2 = 10
Branch analysis from position: 25
Branch analysis from position: 10
filename:       /in/7mXic
function name:  (null)
number of ops:  26
compiled vars:  !0 = $iterator, !1 = $key, !2 = $value
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                                                      ->22
   24    10    >   INIT_METHOD_CALL                                         !0, 'key'
         11        DO_FCALL                                      0  $9      
         12        ASSIGN                                                   !1, $9
   25    13        INIT_METHOD_CALL                                         !0, 'current'
         14        DO_FCALL                                      0  $11     
         15        ASSIGN                                                   !2, $11
   26    16        INIT_FCALL                                               'var_dump'
         17        SEND_VAR                                                 !1
         18        SEND_VAR                                                 !2
         19        DO_ICALL                                                 
   27    20        INIT_METHOD_CALL                                         !0, 'next'
         21        DO_FCALL                                      0          
   23    22    >   INIT_METHOD_CALL                                         !0, 'valid'
         23        DO_FCALL                                      0  $15     
         24      > JMPNZ                                                    $15, ->10
   28    25    > > RETURN                                                   1

Class ObjectKeyIterator:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7mXic
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/7mXic
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:
142.41 ms | 1400 KiB | 15 Q