3v4l.org

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

Class a:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JkbND
function name:  __construct
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 __construct

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/JkbND
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/JkbND
function name:  current
number of ops:  6
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
   40     3        FETCH_OBJ_R                                      ~3      !0
          4      > RETURN                                                   ~3
   41     5*     > 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/JkbND
function name:  key
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   45     0  E >   FETCH_OBJ_R                                      ~1      'pointer'
          1        FETCH_OBJ_R                                      ~0      'keys'
          2        FETCH_DIM_R                                      ~2      ~0, ~1
          3      > RETURN                                                   ~2
   46     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/JkbND
function name:  next
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   50     0  E >   PRE_INC_OBJ                                              'pointer'
   51     1      > RETURN                                                   null

End of function next

Function valid:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 5, Position 2 = 11
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
filename:       /in/JkbND
function name:  valid
number of ops:  13
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   55     0  E >   FETCH_OBJ_R                                      ~0      'pointer'
          1        FETCH_OBJ_R                                      ~1      'keys'
          2        COUNT                                            ~2      ~1
          3        IS_SMALLER                                       ~3      ~0, ~2
          4      > JMPZ_EX                                          ~3      ~3, ->11
          5    >   FETCH_OBJ_R                                      ~5      'pointer'
          6        FETCH_OBJ_R                                      ~4      'keys'
          7        FETCH_DIM_R                                      ~6      ~4, ~5
          8        FETCH_OBJ_R                                      ~7      ~6
          9        TYPE_CHECK                                  1020  ~8      ~7
         10        BOOL                                             ~3      ~8
         11    > > RETURN                                                   ~3
   56    12*     > 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/JkbND
function name:  rewind
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   60     0  E >   ASSIGN_OBJ                                               'pointer'
          1        OP_DATA                                                  0
   61     2      > RETURN                                                   null

End of function rewind

End of class a.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
187.24 ms | 1396 KiB | 15 Q