3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyIterator implements Iterator { private $var = array(); public function __construct($array) { if (is_array($array)) { $this->var = $array; } } public function rewind() { echo "перемотка в начало\n"; reset($this->var); } public function current() { $var = current($this->var); echo "текущий: $var\n"; return $var; } public function key() { $var = key($this->var); echo "ключ: $var\n"; return $var; } public function next() { $var = next($this->var); echo "следующий: $var\n"; return $var; } public function valid() { $key = key($this->var); $var = ($key !== NULL && $key !== FALSE); echo "верный: $var\n"; return $var; } } $values = array(1,2,3); $it = new MyIterator($values); array_map(function($v) { var_dump($v); }, $it);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ooYtJ
function name:  (null)
number of ops:  12
compiled vars:  !0 = $values, !1 = $it
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'myiterator'
   51     1        ASSIGN                                                   !0, <array>
   52     2        NEW                                              $3      'MyIterator'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !1, $3
   54     6        INIT_FCALL                                               'array_map'
          7        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FooYtJ%3A54%241'
   58     8        SEND_VAL                                                 ~6
          9        SEND_VAR                                                 !1
         10        DO_ICALL                                                 
         11      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FooYtJ%3A54%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ooYtJ
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $v
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   54     0  E >   RECV                                             !0      
   56     1        INIT_FCALL                                               'var_dump'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                                 
   58     4      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FooYtJ%3A54%241

Class MyIterator:
Function __construct:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 5
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
filename:       /in/ooYtJ
function name:  __construct
number of ops:  6
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    9     1        TYPE_CHECK                                  128          !0
          2      > JMPZ                                                     ~1, ->5
   10     3    >   ASSIGN_OBJ                                               'var'
          4        OP_DATA                                                  !0
   12     5    > > RETURN                                                   null

End of function __construct

Function rewind:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ooYtJ
function name:  rewind
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   ECHO                                                     '%D0%BF%D0%B5%D1%80%D0%B5%D0%BC%D0%BE%D1%82%D0%BA%D0%B0+%D0%B2+%D0%BD%D0%B0%D1%87%D0%B0%D0%BB%D0%BE%0A'
   17     1        INIT_FCALL                                               'reset'
          2        FETCH_OBJ_W                                      $0      'var'
          3        SEND_REF                                                 $0
          4        DO_ICALL                                                 
   18     5      > RETURN                                                   null

End of function rewind

Function current:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ooYtJ
function name:  current
number of ops:  11
compiled vars:  !0 = $var
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   INIT_FCALL                                               'current'
          1        FETCH_OBJ_R                                      ~1      'var'
          2        SEND_VAL                                                 ~1
          3        DO_ICALL                                         $2      
          4        ASSIGN                                                   !0, $2
   23     5        ROPE_INIT                                     3  ~5      '%D1%82%D0%B5%D0%BA%D1%83%D1%89%D0%B8%D0%B9%3A+'
          6        ROPE_ADD                                      1  ~5      ~5, !0
          7        ROPE_END                                      2  ~4      ~5, '%0A'
          8        ECHO                                                     ~4
   24     9      > RETURN                                                   !0
   25    10*     > 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/ooYtJ
function name:  key
number of ops:  11
compiled vars:  !0 = $var
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   INIT_FCALL                                               'key'
          1        FETCH_OBJ_R                                      ~1      'var'
          2        SEND_VAL                                                 ~1
          3        DO_ICALL                                         $2      
          4        ASSIGN                                                   !0, $2
   30     5        ROPE_INIT                                     3  ~5      '%D0%BA%D0%BB%D1%8E%D1%87%3A+'
          6        ROPE_ADD                                      1  ~5      ~5, !0
          7        ROPE_END                                      2  ~4      ~5, '%0A'
          8        ECHO                                                     ~4
   31     9      > RETURN                                                   !0
   32    10*     > 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/ooYtJ
function name:  next
number of ops:  11
compiled vars:  !0 = $var
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   36     0  E >   INIT_FCALL                                               'next'
          1        FETCH_OBJ_W                                      $1      'var'
          2        SEND_REF                                                 $1
          3        DO_ICALL                                         $2      
          4        ASSIGN                                                   !0, $2
   37     5        ROPE_INIT                                     3  ~5      '%D1%81%D0%BB%D0%B5%D0%B4%D1%83%D1%8E%D1%89%D0%B8%D0%B9%3A+'
          6        ROPE_ADD                                      1  ~5      ~5, !0
          7        ROPE_END                                      2  ~4      ~5, '%0A'
          8        ECHO                                                     ~4
   38     9      > RETURN                                                   !0
   39    10*     > RETURN                                                   null

End of function next

Function valid:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 7, Position 2 = 9
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
filename:       /in/ooYtJ
function name:  valid
number of ops:  16
compiled vars:  !0 = $key, !1 = $var
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   43     0  E >   INIT_FCALL                                               'key'
          1        FETCH_OBJ_R                                      ~2      'var'
          2        SEND_VAL                                                 ~2
          3        DO_ICALL                                         $3      
          4        ASSIGN                                                   !0, $3
   44     5        TYPE_CHECK                                  1020  ~5      !0
          6      > JMPZ_EX                                          ~5      ~5, ->9
          7    >   TYPE_CHECK                                  1018  ~6      !0
          8        BOOL                                             ~5      ~6
          9    >   ASSIGN                                                   !1, ~5
   45    10        ROPE_INIT                                     3  ~9      '%D0%B2%D0%B5%D1%80%D0%BD%D1%8B%D0%B9%3A+'
         11        ROPE_ADD                                      1  ~9      ~9, !1
         12        ROPE_END                                      2  ~8      ~9, '%0A'
         13        ECHO                                                     ~8
   46    14      > RETURN                                                   !1
   47    15*     > RETURN                                                   null

End of function valid

End of class MyIterator.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.45 ms | 1409 KiB | 25 Q