3v4l.org

run code in 500+ 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 ($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 = 20, Position 2 = 29
Branch analysis from position: 20
2 jumps found. (Code = 78) Position 1 = 21, Position 2 = 29
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 28
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
Branch analysis from position: 28
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
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/8Bnd3
function name:  (null)
number of ops:  36
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      > FE_RESET_R                                           $14     !0, ->29
         20    > > FE_FETCH_R                                                   $14, !2, ->29
   20    21    >   INIT_METHOD_CALL                                             !0, 'contains'
         22        SEND_VAR_EX                                                  !2
         23        DO_FCALL                                          0  $15     
         24      > JMPZ                                                         $15, ->28
   21    25    >   INIT_METHOD_CALL                                             !0, 'detach'
         26        SEND_VAR_EX                                                  !2
         27        DO_FCALL                                          0          
   19    28    > > JMP                                                          ->20
         29    >   FE_FREE                                                      $14
   25    30        ECHO                                                         'Expected+count+after+detach%3A+0%0A'
   26    31        INIT_METHOD_CALL                                             !0, 'count'
         32        DO_FCALL                                          0  $17     
         33        CONCAT                                               ~18     'Actual+count+after+detach%3A+', $17
         34        ECHO                                                         ~18
         35      > RETURN                                                       1

Function getobject:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8Bnd3
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.5.0


preferences:
142.64 ms | 509 KiB | 10 Q