3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { public $val; public function __construct($val) { $this->val = $val; } } $storage = new SplObjectStorage; for($i = 1; $i <= 10; $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) { $storage->detach($object); //echo ' - deleted Object A(' . $object->val . ') '; } //echo PHP_EOL; } echo 'Number of iterations: ' . $iterations . PHP_EOL;
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 = 5
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
2 jumps found. (Code = 44) Position 1 = 35, Position 2 = 18
Branch analysis from position: 35
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
2 jumps found. (Code = 47) Position 1 = 26, Position 2 = 28
Branch analysis from position: 26
2 jumps found. (Code = 43) Position 1 = 29, Position 2 = 32
Branch analysis from position: 29
2 jumps found. (Code = 44) Position 1 = 35, Position 2 = 18
Branch analysis from position: 35
Branch analysis from position: 18
Branch analysis from position: 32
Branch analysis from position: 28
Branch analysis from position: 5
2 jumps found. (Code = 44) Position 1 = 14, Position 2 = 5
Branch analysis from position: 14
Branch analysis from position: 5
filename:       /in/VTRfW
function name:  (null)
number of ops:  39
compiled vars:  !0 = $storage, !1 = $i, !2 = $iterations, !3 = $object
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   NEW                                              $4      'SplObjectStorage'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $4
    8     3        ASSIGN                                                   !1, 1
          4      > JMP                                                      ->12
    9     5    >   INIT_METHOD_CALL                                         !0, 'attach'
          6        NEW                                              $8      'A'
          7        SEND_VAR_EX                                              !1
          8        DO_FCALL                                      0          
          9        SEND_VAR_NO_REF_EX                                       $8
         10        DO_FCALL                                      0          
    8    11        PRE_INC                                                  !1
         12    >   IS_SMALLER_OR_EQUAL                                      !1, 10
         13      > JMPNZ                                                    ~12, ->5
   11    14    >   ASSIGN                                                   !2, 0
   12    15        INIT_METHOD_CALL                                         !0, 'rewind'
         16        DO_FCALL                                      0          
   13    17      > JMP                                                      ->32
   14    18    >   PRE_INC                                                  !2
   15    19        INIT_METHOD_CALL                                         !0, 'current'
         20        DO_FCALL                                      0  $16     
         21        ASSIGN                                                   !3, $16
   17    22        INIT_METHOD_CALL                                         !0, 'next'
         23        DO_FCALL                                      0          
   18    24        IS_IDENTICAL                                     ~19     !2, 2
         25      > JMPNZ_EX                                         ~19     ~19, ->28
         26    >   IS_IDENTICAL                                     ~20     !2, 8
         27        BOOL                                             ~19     ~20
         28    > > JMPZ                                                     ~19, ->32
   19    29    >   INIT_METHOD_CALL                                         !0, 'detach'
         30        SEND_VAR_EX                                              !3
         31        DO_FCALL                                      0          
   13    32    >   INIT_METHOD_CALL                                         !0, 'valid'
         33        DO_FCALL                                      0  $22     
         34      > JMPNZ                                                    $22, ->18
   24    35    >   CONCAT                                           ~23     'Number+of+iterations%3A+', !2
         36        CONCAT                                           ~24     ~23, '%0A'
         37        ECHO                                                     ~24
         38      > RETURN                                                   1

Class A:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VTRfW
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:
154.3 ms | 1399 KiB | 13 Q