3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { public $val; public function __construct($val) { $this->val = $val; } } $storage = new SplObjectStorage; $expected = 10; // 10 iterations is expected, as storage has 10 objects attached for($i = 1; $i <= $expected; $i++) { $storage->attach(new A($i)); } $iterations = 0; $storage->rewind(); while ($storage->valid()) { $iterations++; $object = $storage->current(); echo 'Iteration #' . $iterations . ' with object A(' . $object->val . ')'; $storage->next(); if($iterations === 2 || $iterations === 8) { echo ' - deleted Object A(' . $object->val . ') ';// . PHP_EOL; $storage->detach($object); // continue; } echo PHP_EOL; } if(count($storage) != $iterations) { echo 'Error! - too much iterations!' . PHP_EOL; } else { echo 'Success - there was 10 iterations as expected.' . PHP_EOL; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
2 jumps found. (Code = 44) Position 1 = 15, Position 2 = 6
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 44
Branch analysis from position: 44
2 jumps found. (Code = 44) Position 1 = 47, Position 2 = 19
Branch analysis from position: 47
2 jumps found. (Code = 43) Position 1 = 50, Position 2 = 52
Branch analysis from position: 50
1 jumps found. (Code = 42) Position 1 = 53
Branch analysis from position: 53
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 52
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
2 jumps found. (Code = 47) Position 1 = 33, Position 2 = 35
Branch analysis from position: 33
2 jumps found. (Code = 43) Position 1 = 36, Position 2 = 43
Branch analysis from position: 36
2 jumps found. (Code = 44) Position 1 = 47, Position 2 = 19
Branch analysis from position: 47
Branch analysis from position: 19
Branch analysis from position: 43
Branch analysis from position: 35
Branch analysis from position: 6
2 jumps found. (Code = 44) Position 1 = 15, Position 2 = 6
Branch analysis from position: 15
Branch analysis from position: 6
filename:       /in/JAZBJ
function name:  (null)
number of ops:  54
compiled vars:  !0 = $storage, !1 = $expected, !2 = $i, !3 = $iterations, !4 = $object
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   NEW                                              $5      'SplObjectStorage'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $5
   10     3        ASSIGN                                                   !1, 10
   11     4        ASSIGN                                                   !2, 1
          5      > JMP                                                      ->13
   12     6    >   INIT_METHOD_CALL                                         !0, 'attach'
          7        NEW                                              $10     'A'
          8        SEND_VAR_EX                                              !2
          9        DO_FCALL                                      0          
         10        SEND_VAR_NO_REF_EX                                       $10
         11        DO_FCALL                                      0          
   11    12        PRE_INC                                                  !2
         13    >   IS_SMALLER_OR_EQUAL                                      !2, !1
         14      > JMPNZ                                                    ~14, ->6
   15    15    >   ASSIGN                                                   !3, 0
   17    16        INIT_METHOD_CALL                                         !0, 'rewind'
         17        DO_FCALL                                      0          
   18    18      > JMP                                                      ->44
   19    19    >   PRE_INC                                                  !3
   20    20        INIT_METHOD_CALL                                         !0, 'current'
         21        DO_FCALL                                      0  $18     
         22        ASSIGN                                                   !4, $18
   21    23        CONCAT                                           ~20     'Iteration+%23', !3
         24        CONCAT                                           ~21     ~20, '+with+object+A%28'
         25        FETCH_OBJ_R                                      ~22     !4, 'val'
         26        CONCAT                                           ~23     ~21, ~22
         27        CONCAT                                           ~24     ~23, '%29'
         28        ECHO                                                     ~24
   22    29        INIT_METHOD_CALL                                         !0, 'next'
         30        DO_FCALL                                      0          
   23    31        IS_IDENTICAL                                     ~26     !3, 2
         32      > JMPNZ_EX                                         ~26     ~26, ->35
         33    >   IS_IDENTICAL                                     ~27     !3, 8
         34        BOOL                                             ~26     ~27
         35    > > JMPZ                                                     ~26, ->43
   24    36    >   FETCH_OBJ_R                                      ~28     !4, 'val'
         37        CONCAT                                           ~29     '+-+deleted+Object+A%28', ~28
         38        CONCAT                                           ~30     ~29, '%29+'
         39        ECHO                                                     ~30
   25    40        INIT_METHOD_CALL                                         !0, 'detach'
         41        SEND_VAR_EX                                              !4
         42        DO_FCALL                                      0          
   29    43    >   ECHO                                                     '%0A'
   18    44    >   INIT_METHOD_CALL                                         !0, 'valid'
         45        DO_FCALL                                      0  $32     
         46      > JMPNZ                                                    $32, ->19
   32    47    >   COUNT                                            ~33     !0
         48        IS_NOT_EQUAL                                             !3, ~33
         49      > JMPZ                                                     ~34, ->52
   33    50    >   ECHO                                                     'Error%21+-+too+much+iterations%21%0A'
         51      > JMP                                                      ->53
   35    52    >   ECHO                                                     'Success+-+there+was+10+iterations+as+expected.%0A'
   36    53    > > RETURN                                                   1

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

End of function __construct

End of class A.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
178.21 ms | 1399 KiB | 13 Q