3v4l.org

run code in 300+ PHP versions simultaneously
<?php class a implements \Iterator, \Countable { private $a; private $b; private $c; private $keys = [ 'a', 'b', 'c' ]; private $pointer; public function __construc($a = null, $b = null, $c = null) { $this->a = $a; $this->b = $b; $this->c = $c; } public function count() { $pointer = 0; foreach ($this as $element) { if ($element) { $pointer++; } } return $pointer; } public function current() { $key = $this->key(); var_dump($key); return $this->{$key}; } public function key() { $this->keys[$this->pointer]; } public function next() { $this->pointer++; } public function valid() { return $this->pointer < count($this->keys); } public function rewind() { $this->pointer = 0; } } $me = new a('a'); var_dump($me->count()); foreach ($me as $key => $el) { var_dump($key, $el); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 18
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 18
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
filename:       /in/hkarD
function name:  (null)
number of ops:  20
compiled vars:  !0 = $me, !1 = $el, !2 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   DECLARE_CLASS                                            'a'
   65     1        NEW                                              $3      'a'
          2        SEND_VAL_EX                                              'a'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $3
   67     5        INIT_FCALL                                               'var_dump'
          6        INIT_METHOD_CALL                                         !0, 'count'
          7        DO_FCALL                                      0  $6      
          8        SEND_VAR                                                 $6
          9        DO_ICALL                                                 
   69    10      > FE_RESET_R                                       $8      !0, ->18
         11    > > FE_FETCH_R                                       ~9      $8, !1, ->18
         12    >   ASSIGN                                                   !2, ~9
   70    13        INIT_FCALL                                               'var_dump'
         14        SEND_VAR                                                 !2
         15        SEND_VAR                                                 !1
         16        DO_ICALL                                                 
   69    17      > JMP                                                      ->11
         18    >   FE_FREE                                                  $8
   71    19      > RETURN                                                   1

Class a:
Function __construc:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hkarD
function name:  __construc
number of ops:  10
compiled vars:  !0 = $a, !1 = $b, !2 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV_INIT                                        !0      null
          1        RECV_INIT                                        !1      null
          2        RECV_INIT                                        !2      null
   19     3        ASSIGN_OBJ                                               'a'
          4        OP_DATA                                                  !0
   20     5        ASSIGN_OBJ                                               'b'
          6        OP_DATA                                                  !1
   21     7        ASSIGN_OBJ                                               'c'
          8        OP_DATA                                                  !2
   22     9      > RETURN                                                   null

End of function __construc

Function count:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 7
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 7
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 6
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 6
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
filename:       /in/hkarD
function name:  count
number of ops:  10
compiled vars:  !0 = $pointer, !1 = $element
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   ASSIGN                                                   !0, 0
   28     1        FETCH_THIS                                       ~3      
          2      > FE_RESET_R                                       $4      ~3, ->7
          3    > > FE_FETCH_R                                               $4, !1, ->7
   29     4    > > JMPZ                                                     !1, ->6
   30     5    >   PRE_INC                                                  !0
   28     6    > > JMP                                                      ->3
          7    >   FE_FREE                                                  $4
   34     8      > RETURN                                                   !0
   35     9*     > RETURN                                                   null

End of function count

Function current:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hkarD
function name:  current
number of ops:  9
compiled vars:  !0 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   39     0  E >   INIT_METHOD_CALL                                         'key'
          1        DO_FCALL                                      0  $1      
          2        ASSIGN                                                   !0, $1
          3        INIT_FCALL                                               'var_dump'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                                 
   41     6        FETCH_OBJ_R                                      ~4      !0
          7      > RETURN                                                   ~4
   42     8*     > 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/hkarD
function name:  key
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   46     0  E >   FETCH_OBJ_R                                      ~1      'pointer'
          1        FETCH_OBJ_R                                      ~0      'keys'
          2        FETCH_DIM_R                                      ~2      ~0, ~1
          3        FREE                                                     ~2
   47     4      > 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/hkarD
function name:  next
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   51     0  E >   PRE_INC_OBJ                                              'pointer'
   52     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/hkarD
function name:  valid
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   56     0  E >   FETCH_OBJ_R                                      ~0      'pointer'
          1        FETCH_OBJ_R                                      ~1      'keys'
          2        COUNT                                            ~2      ~1
          3        IS_SMALLER                                       ~3      ~0, ~2
          4      > RETURN                                                   ~3
   57     5*     > RETURN                                                   null

End of function valid

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

End of function rewind

End of class a.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
215.9 ms | 1404 KiB | 15 Q