3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { public $val; public function __construct($val) { $this->val = $val; } } $storage = new SplObjectStorage; $storage->attach(new A(1)); $storage->attach(new A(2)); $storage->attach(new A(3)); $storage->attach(new A(4)); $storage->attach(new A(5)); $storage->attach(new A(6)); $storage->attach(new A(7)); $storage->attach(new A(8)); $storage->attach(new A(9)); $storage->attach(new A(10)); $iterations = 0; $expected = 10; // 10 iterations is expected, as storage has 10 objects attached $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!' . PHP_EOL; } else { echo 'Success!' . PHP_EOL; } exit;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 95
Branch analysis from position: 95
2 jumps found. (Code = 44) Position 1 = 98, Position 2 = 68
Branch analysis from position: 98
2 jumps found. (Code = 43) Position 1 = 101, Position 2 = 103
Branch analysis from position: 101
1 jumps found. (Code = 42) Position 1 = 104
Branch analysis from position: 104
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 103
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 68
2 jumps found. (Code = 47) Position 1 = 82, Position 2 = 84
Branch analysis from position: 82
2 jumps found. (Code = 43) Position 1 = 85, Position 2 = 94
Branch analysis from position: 85
1 jumps found. (Code = 42) Position 1 = 95
Branch analysis from position: 95
Branch analysis from position: 94
2 jumps found. (Code = 44) Position 1 = 98, Position 2 = 68
Branch analysis from position: 98
Branch analysis from position: 68
Branch analysis from position: 84
filename:       /in/1N4FO
function name:  (null)
number of ops:  106
compiled vars:  !0 = $storage, !1 = $iterations, !2 = $expected, !3 = $object
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   NEW                                              $4      'SplObjectStorage'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $4
   11     3        INIT_METHOD_CALL                                         !0, 'attach'
          4        NEW                                              $7      'A'
          5        SEND_VAL_EX                                              1
          6        DO_FCALL                                      0          
          7        SEND_VAR_NO_REF_EX                                       $7
          8        DO_FCALL                                      0          
   12     9        INIT_METHOD_CALL                                         !0, 'attach'
         10        NEW                                              $10     'A'
         11        SEND_VAL_EX                                              2
         12        DO_FCALL                                      0          
         13        SEND_VAR_NO_REF_EX                                       $10
         14        DO_FCALL                                      0          
   13    15        INIT_METHOD_CALL                                         !0, 'attach'
         16        NEW                                              $13     'A'
         17        SEND_VAL_EX                                              3
         18        DO_FCALL                                      0          
         19        SEND_VAR_NO_REF_EX                                       $13
         20        DO_FCALL                                      0          
   14    21        INIT_METHOD_CALL                                         !0, 'attach'
         22        NEW                                              $16     'A'
         23        SEND_VAL_EX                                              4
         24        DO_FCALL                                      0          
         25        SEND_VAR_NO_REF_EX                                       $16
         26        DO_FCALL                                      0          
   15    27        INIT_METHOD_CALL                                         !0, 'attach'
         28        NEW                                              $19     'A'
         29        SEND_VAL_EX                                              5
         30        DO_FCALL                                      0          
         31        SEND_VAR_NO_REF_EX                                       $19
         32        DO_FCALL                                      0          
   16    33        INIT_METHOD_CALL                                         !0, 'attach'
         34        NEW                                              $22     'A'
         35        SEND_VAL_EX                                              6
         36        DO_FCALL                                      0          
         37        SEND_VAR_NO_REF_EX                                       $22
         38        DO_FCALL                                      0          
   17    39        INIT_METHOD_CALL                                         !0, 'attach'
         40        NEW                                              $25     'A'
         41        SEND_VAL_EX                                              7
         42        DO_FCALL                                      0          
         43        SEND_VAR_NO_REF_EX                                       $25
         44        DO_FCALL                                      0          
   18    45        INIT_METHOD_CALL                                         !0, 'attach'
         46        NEW                                              $28     'A'
         47        SEND_VAL_EX                                              8
         48        DO_FCALL                                      0          
         49        SEND_VAR_NO_REF_EX                                       $28
         50        DO_FCALL                                      0          
   19    51        INIT_METHOD_CALL                                         !0, 'attach'
         52        NEW                                              $31     'A'
         53        SEND_VAL_EX                                              9
         54        DO_FCALL                                      0          
         55        SEND_VAR_NO_REF_EX                                       $31
         56        DO_FCALL                                      0          
   20    57        INIT_METHOD_CALL                                         !0, 'attach'
         58        NEW                                              $34     'A'
         59        SEND_VAL_EX                                              10
         60        DO_FCALL                                      0          
         61        SEND_VAR_NO_REF_EX                                       $34
         62        DO_FCALL                                      0          
   22    63        ASSIGN                                                   !1, 0
   23    64        ASSIGN                                                   !2, 10
   25    65        INIT_METHOD_CALL                                         !0, 'rewind'
         66        DO_FCALL                                      0          
   26    67      > JMP                                                      ->95
   27    68    >   PRE_INC                                                  !1
   28    69        INIT_METHOD_CALL                                         !0, 'current'
         70        DO_FCALL                                      0  $41     
         71        ASSIGN                                                   !3, $41
   29    72        CONCAT                                           ~43     'Iteration+%23', !1
         73        CONCAT                                           ~44     ~43, '+with+object+A%28'
         74        FETCH_OBJ_R                                      ~45     !3, 'val'
         75        CONCAT                                           ~46     ~44, ~45
         76        CONCAT                                           ~47     ~46, '%29'
         77        ECHO                                                     ~47
   30    78        INIT_METHOD_CALL                                         !0, 'next'
         79        DO_FCALL                                      0          
   32    80        IS_IDENTICAL                                     ~49     !1, 2
         81      > JMPNZ_EX                                         ~49     ~49, ->84
         82    >   IS_IDENTICAL                                     ~50     !1, 8
         83        BOOL                                             ~49     ~50
         84    > > JMPZ                                                     ~49, ->94
   33    85    >   FETCH_OBJ_R                                      ~51     !3, 'val'
         86        CONCAT                                           ~52     '+-+deleted+Object+A%28', ~51
         87        CONCAT                                           ~53     ~52, '%29+'
         88        CONCAT                                           ~54     ~53, '%0A'
         89        ECHO                                                     ~54
   34    90        INIT_METHOD_CALL                                         !0, 'detach'
         91        SEND_VAR_EX                                              !3
         92        DO_FCALL                                      0          
   35    93      > JMP                                                      ->95
   38    94    >   ECHO                                                     '%0A'
   26    95    >   INIT_METHOD_CALL                                         !0, 'valid'
         96        DO_FCALL                                      0  $56     
         97      > JMPNZ                                                    $56, ->68
   41    98    >   COUNT                                            ~57     !0
         99        IS_NOT_EQUAL                                             !1, ~57
        100      > JMPZ                                                     ~58, ->103
   42   101    >   ECHO                                                     'Error%21%0A'
        102      > JMP                                                      ->104
   44   103    >   ECHO                                                     'Success%21%0A'
   47   104    > > EXIT                                                     
        105*     > RETURN                                                   1

Class A:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1N4FO
function name:  __construct
number of ops:  4
compiled vars:  !0 = $val
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     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:
144.64 ms | 1403 KiB | 13 Q