3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Test { function run() { $this->arr = array('item'); var_dump(key($this->arr)); // dumps 0 // this unexpectedly advances the internal array pointer foreach ($this->getArr() as $v) {} var_dump(key($this->arr)); // dumps NULL } function getArr() { // is NOT returned by reference return $this->arr; } } $test = new Test; $test->run();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/FlKBC
function name:  (null)
number of ops:  6
compiled vars:  !0 = $test
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   NEW                                              $1      'Test'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   26     3        INIT_METHOD_CALL                                         !0, 'run'
          4        DO_FCALL                                      0          
          5      > RETURN                                                   1

Class Test:
Function run:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 12, Position 2 = 14
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 14
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
filename:       /in/FlKBC
function name:  run
number of ops:  23
compiled vars:  !0 = $v
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   ASSIGN_OBJ                                               'arr'
          1        OP_DATA                                                  <array>
    8     2        INIT_FCALL                                               'var_dump'
          3        INIT_FCALL                                               'key'
          4        FETCH_OBJ_R                                      ~2      'arr'
          5        SEND_VAL                                                 ~2
          6        DO_ICALL                                         $3      
          7        SEND_VAR                                                 $3
          8        DO_ICALL                                                 
   11     9        INIT_METHOD_CALL                                         'getArr'
         10        DO_FCALL                                      0  $5      
         11      > FE_RESET_R                                       $6      $5, ->14
         12    > > FE_FETCH_R                                               $6, !0, ->14
         13    > > JMP                                                      ->12
         14    >   FE_FREE                                                  $6
   13    15        INIT_FCALL                                               'var_dump'
         16        INIT_FCALL                                               'key'
         17        FETCH_OBJ_R                                      ~7      'arr'
         18        SEND_VAL                                                 ~7
         19        DO_ICALL                                         $8      
         20        SEND_VAR                                                 $8
         21        DO_ICALL                                                 
   14    22      > RETURN                                                   null

End of function run

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

End of function getarr

End of class Test.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.07 ms | 1400 KiB | 17 Q