3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyModel { } class Collection implements \ArrayAccess, \Iterator { private $storage = array(); public function offsetExists($offset) { return isset($this->storage[$offset]); } public function offsetGet($offset) { return $this->storage[$offset]; } public function offsetSet($offset, $value) { if (null === $offset) { $this->storage[] = $value; } else { $this->storage[$offset] = $value; } } public function offsetUnset($offset) { echo 'trying to unset ' . $offset . PHP_EOL; unset($this->storage[$offset]); key($this->storage); } public function current() { return current($this->storage); } public function next() { return next($this->storage); } public function key() { return key($this->storage); } public function valid() { return key($this->storage) !== null; } public function rewind() { reset($this->storage); } public function count() { return count($this->storage); } } class MyCollectionModel { private $collection; public function __construct() { $this->collection = new Collection(); } public function addElement($element) { $this->collection[] = $element; } public function removeMyModels() { foreach ($this->collection as $index => $value) { var_dump($index); if ($value instanceof MyModel) { unset ($this->collection[$index]); } } } } // Создем коллекцию $myCollection = new MyCollectionModel(); // Заполняем своими можельками for ($i = 0; $i < 10; $i++) { $myCollection->addElement(new MyModel()); } // Удаляем свои модельки $myCollection->removeMyModels(); // Сука, ебучая PHP!!! print_r($myCollection);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
2 jumps found. (Code = 44) Position 1 = 14, Position 2 = 6
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
2 jumps found. (Code = 44) Position 1 = 14, Position 2 = 6
Branch analysis from position: 14
Branch analysis from position: 6
filename:       /in/fV5hS
function name:  (null)
number of ops:  20
compiled vars:  !0 = $myCollection, !1 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   DECLARE_CLASS                                            'collection'
   94     1        NEW                                              $2      'MyCollectionModel'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $2
   97     4        ASSIGN                                                   !1, 0
          5      > JMP                                                      ->12
   98     6    >   INIT_METHOD_CALL                                         !0, 'addElement'
          7        NEW                                              $6      'MyModel'
          8        DO_FCALL                                      0          
          9        SEND_VAR_NO_REF_EX                                       $6
         10        DO_FCALL                                      0          
   97    11        PRE_INC                                                  !1
         12    >   IS_SMALLER                                               !1, 10
         13      > JMPNZ                                                    ~10, ->6
  102    14    >   INIT_METHOD_CALL                                         !0, 'removeMyModels'
         15        DO_FCALL                                      0          
  105    16        INIT_FCALL                                               'print_r'
         17        SEND_VAR                                                 !0
         18        DO_ICALL                                                 
         19      > RETURN                                                   1

Class MyModel: [no user functions]
Class Collection:
Function offsetexists:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fV5hS
function name:  offsetExists
number of ops:  5
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
   13     1        FETCH_OBJ_IS                                     ~1      'storage'
          2        ISSET_ISEMPTY_DIM_OBJ                         0  ~2      ~1, !0
          3      > RETURN                                                   ~2
   14     4*     > RETURN                                                   null

End of function offsetexists

Function offsetget:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fV5hS
function name:  offsetGet
number of ops:  5
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
   18     1        FETCH_OBJ_R                                      ~1      'storage'
          2        FETCH_DIM_R                                      ~2      ~1, !0
          3      > RETURN                                                   ~2
   19     4*     > RETURN                                                   null

End of function offsetget

Function offsetset:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 8
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fV5hS
function name:  offsetSet
number of ops:  12
compiled vars:  !0 = $offset, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   23     2        TYPE_CHECK                                    2          !0
          3      > JMPZ                                                     ~2, ->8
   24     4    >   FETCH_OBJ_W                                      $3      'storage'
          5        ASSIGN_DIM                                               $3
          6        OP_DATA                                                  !1
          7      > JMP                                                      ->11
   26     8    >   FETCH_OBJ_W                                      $5      'storage'
          9        ASSIGN_DIM                                               $5, !0
         10        OP_DATA                                                  !1
   28    11    > > RETURN                                                   null

End of function offsetset

Function offsetunset:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fV5hS
function name:  offsetUnset
number of ops:  11
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   RECV                                             !0      
   32     1        CONCAT                                           ~1      'trying+to+unset+', !0
          2        CONCAT                                           ~2      ~1, '%0A'
          3        ECHO                                                     ~2
   33     4        FETCH_OBJ_UNSET                                  $3      'storage'
          5        UNSET_DIM                                                $3, !0
   34     6        INIT_FCALL                                               'key'
          7        FETCH_OBJ_R                                      ~4      'storage'
          8        SEND_VAL                                                 ~4
          9        DO_ICALL                                                 
   35    10      > RETURN                                                   null

End of function offsetunset

Function current:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fV5hS
function name:  current
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   39     0  E >   INIT_FCALL                                               'current'
          1        FETCH_OBJ_R                                      ~0      'storage'
          2        SEND_VAL                                                 ~0
          3        DO_ICALL                                         $1      
          4      > RETURN                                                   $1
   40     5*     > RETURN                                                   null

End of function current

Function next:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fV5hS
function name:  next
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   44     0  E >   INIT_FCALL                                               'next'
          1        FETCH_OBJ_W                                      $0      'storage'
          2        SEND_REF                                                 $0
          3        DO_ICALL                                         $1      
          4      > RETURN                                                   $1
   45     5*     > RETURN                                                   null

End of function next

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

End of function key

Function valid:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fV5hS
function name:  valid
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   54     0  E >   INIT_FCALL                                               'key'
          1        FETCH_OBJ_R                                      ~0      'storage'
          2        SEND_VAL                                                 ~0
          3        DO_ICALL                                         $1      
          4        TYPE_CHECK                                  1020  ~2      $1
          5      > RETURN                                                   ~2
   55     6*     > 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/fV5hS
function name:  rewind
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   59     0  E >   INIT_FCALL                                               'reset'
          1        FETCH_OBJ_W                                      $0      'storage'
          2        SEND_REF                                                 $0
          3        DO_ICALL                                                 
   60     4      > RETURN                                                   null

End of function rewind

Function count:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fV5hS
function name:  count
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   64     0  E >   FETCH_OBJ_R                                      ~0      'storage'
          1        COUNT                                            ~1      ~0
          2      > RETURN                                                   ~1
   65     3*     > RETURN                                                   null

End of function count

End of class Collection.

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

End of function __construct

Function addelement:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fV5hS
function name:  addElement
number of ops:  5
compiled vars:  !0 = $element
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   77     0  E >   RECV                                             !0      
   79     1        FETCH_OBJ_W                                      $1      'collection'
          2        ASSIGN_DIM                                               $1
          3        OP_DATA                                                  !0
   80     4      > RETURN                                                   null

End of function addelement

Function removemymodels:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 12
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 12
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 11
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 11
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
filename:       /in/fV5hS
function name:  removeMyModels
number of ops:  14
compiled vars:  !0 = $value, !1 = $index
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   84     0  E >   FETCH_OBJ_R                                      ~2      'collection'
          1      > FE_RESET_R                                       $3      ~2, ->12
          2    > > FE_FETCH_R                                       ~4      $3, !0, ->12
          3    >   ASSIGN                                                   !1, ~4
   85     4        INIT_FCALL                                               'var_dump'
          5        SEND_VAR                                                 !1
          6        DO_ICALL                                                 
   86     7        INSTANCEOF                                               !0, 'MyModel'
          8      > JMPZ                                                     ~7, ->11
   87     9    >   FETCH_OBJ_UNSET                                  $8      'collection'
         10        UNSET_DIM                                                $8, !1
   84    11    > > JMP                                                      ->2
         12    >   FE_FREE                                                  $3
   90    13      > RETURN                                                   null

End of function removemymodels

End of class MyCollectionModel.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.94 ms | 1408 KiB | 25 Q