3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getObject(int $index): \stdClass { $obj = new \stdClass(); $obj->index = $index; return $obj; } $objectStorage = new \SplObjectStorage(); for ($i = 0; $i < 10; $i++) { $objectStorage->attach(getObject($i)); } echo 'Count before detach: ' . $objectStorage->count() . "\n"; foreach (clone $objectStorage as $object) { if ($objectStorage->contains($object)) { $objectStorage->detach($object); } } echo 'Expected count after detach: 0' . "\n"; echo 'Actual count after detach: ' . $objectStorage->count();
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
2 jumps found. (Code = 77) Position 1 = 21, Position 2 = 30
Branch analysis from position: 21
2 jumps found. (Code = 78) Position 1 = 22, Position 2 = 30
Branch analysis from position: 22
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 29
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
Branch analysis from position: 29
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
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/imCXv
function name:  (null)
number of ops:  37
compiled vars:  !0 = $objectStorage, !1 = $i, !2 = $object
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   NEW                                              $3      'SplObjectStorage'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $3
   13     3        ASSIGN                                                   !1, 0
          4      > JMP                                                      ->12
   14     5    >   INIT_METHOD_CALL                                         !0, 'attach'
          6        INIT_FCALL                                               'getobject'
          7        SEND_VAR                                                 !1
          8        DO_FCALL                                      0  $7      
          9        SEND_VAR_NO_REF_EX                                       $7
         10        DO_FCALL                                      0          
   13    11        PRE_INC                                                  !1
         12    >   IS_SMALLER                                               !1, 10
         13      > JMPNZ                                                    ~10, ->5
   17    14    >   INIT_METHOD_CALL                                         !0, 'count'
         15        DO_FCALL                                      0  $11     
         16        CONCAT                                           ~12     'Count+before+detach%3A+', $11
         17        CONCAT                                           ~13     ~12, '%0A'
         18        ECHO                                                     ~13
   19    19        CLONE                                            ~14     !0
         20      > FE_RESET_R                                       $15     ~14, ->30
         21    > > FE_FETCH_R                                               $15, !2, ->30
   20    22    >   INIT_METHOD_CALL                                         !0, 'contains'
         23        SEND_VAR_EX                                              !2
         24        DO_FCALL                                      0  $16     
         25      > JMPZ                                                     $16, ->29
   21    26    >   INIT_METHOD_CALL                                         !0, 'detach'
         27        SEND_VAR_EX                                              !2
         28        DO_FCALL                                      0          
   19    29    > > JMP                                                      ->21
         30    >   FE_FREE                                                  $15
   25    31        ECHO                                                     'Expected+count+after+detach%3A+0%0A'
   26    32        INIT_METHOD_CALL                                         !0, 'count'
         33        DO_FCALL                                      0  $18     
         34        CONCAT                                           ~19     'Actual+count+after+detach%3A+', $18
         35        ECHO                                                     ~19
         36      > RETURN                                                   1

Function getobject:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/imCXv
function name:  getObject
number of ops:  10
compiled vars:  !0 = $index, !1 = $obj
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1        NEW                                              $2      'stdClass'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $2
    6     4        ASSIGN_OBJ                                               !1, 'index'
          5        OP_DATA                                                  !0
    8     6        VERIFY_RETURN_TYPE                                       !1
          7      > RETURN                                                   !1
    9     8*       VERIFY_RETURN_TYPE                                       
          9*     > RETURN                                                   null

End of function getobject

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
130.77 ms | 1451 KiB | 14 Q