3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyValue { private $value; function get() { return $this->value; } function set($value) { $this->value = $value; } function delete() { $this->value = null; } } class MyIterator implements Iterator { private $data; private $key = 0; function __construct() { $this->data = new MyValue(); } function __destruct() { $this->data->delete(); } function current() { $this->data->set($this->key); return $this->data; } function key() { return $this->key; } function next() { ++$this->key; } function rewind() { $this->key = 0; } function valid() { return $this->key < 10; } } function iterate() { $out = array(); $values = new MyIterator(); foreach ($values as $value) { $out[] = $value; } print_r($out); return $out; } $values = iterate(); print_r($values);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/aXaT1
function name:  (null)
number of ops:  8
compiled vars:  !0 = $values
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   DECLARE_CLASS                                            'myiterator'
   64     1        INIT_FCALL                                               'iterate'
          2        DO_FCALL                                      0  $1      
          3        ASSIGN                                                   !0, $1
   65     4        INIT_FCALL                                               'print_r'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                                 
          7      > RETURN                                                   1

Function iterate:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 9
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 9
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
filename:       /in/aXaT1
function name:  iterate
number of ops:  15
compiled vars:  !0 = $out, !1 = $values, !2 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   55     0  E >   ASSIGN                                                   !0, <array>
   56     1        NEW                                              $4      'MyIterator'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $4
   57     4      > FE_RESET_R                                       $7      !1, ->9
          5    > > FE_FETCH_R                                               $7, !2, ->9
   58     6    >   ASSIGN_DIM                                               !0
          7        OP_DATA                                                  !2
   57     8      > JMP                                                      ->5
          9    >   FE_FREE                                                  $7
   60    10        INIT_FCALL                                               'print_r'
         11        SEND_VAR                                                 !0
         12        DO_ICALL                                                 
   61    13      > RETURN                                                   !0
   62    14*     > RETURN                                                   null

End of function iterate

Class MyValue:
Function get:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/aXaT1
function name:  get
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   FETCH_OBJ_R                                      ~0      'value'
          1      > RETURN                                                   ~0
    8     2*     > RETURN                                                   null

End of function get

Function set:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/aXaT1
function name:  set
number of ops:  4
compiled vars:  !0 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
   11     1        ASSIGN_OBJ                                               'value'
          2        OP_DATA                                                  !0
   12     3      > RETURN                                                   null

End of function set

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

End of function delete

End of class MyValue.

Class MyIterator:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/aXaT1
function name:  __construct
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   NEW                                              $1      'MyValue'
          1        DO_FCALL                                      0          
          2        ASSIGN_OBJ                                               'data'
          3        OP_DATA                                                  $1
   25     4      > RETURN                                                   null

End of function __construct

Function __destruct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/aXaT1
function name:  __destruct
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   FETCH_OBJ_R                                      ~0      'data'
          1        INIT_METHOD_CALL                                         ~0, 'delete'
          2        DO_FCALL                                      0          
   29     3      > RETURN                                                   null

End of function __destruct

Function current:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/aXaT1
function name:  current
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   FETCH_OBJ_R                                      ~0      'data'
          1        INIT_METHOD_CALL                                         ~0, 'set'
          2        CHECK_FUNC_ARG                                           
          3        FETCH_OBJ_FUNC_ARG                               $1      'key'
          4        SEND_FUNC_ARG                                            $1
          5        DO_FCALL                                      0          
   33     6        FETCH_OBJ_R                                      ~3      'data'
          7      > RETURN                                                   ~3
   34     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/aXaT1
function name:  key
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   37     0  E >   FETCH_OBJ_R                                      ~0      'key'
          1      > RETURN                                                   ~0
   38     2*     > 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/aXaT1
function name:  next
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   41     0  E >   PRE_INC_OBJ                                              'key'
   42     1      > RETURN                                                   null

End of function next

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

End of function rewind

Function valid:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/aXaT1
function name:  valid
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   49     0  E >   FETCH_OBJ_R                                      ~0      'key'
          1        IS_SMALLER                                       ~1      ~0, 10
          2      > RETURN                                                   ~1
   50     3*     > RETURN                                                   null

End of function valid

End of class MyIterator.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.9 ms | 1407 KiB | 16 Q