3v4l.org

run code in 300+ PHP versions simultaneously
<?php class IdObjectStorage extends SplObjectStorage { public function getHash($object) { return (string) $object->id; } } $storage = new IdObjectStorage(); $array = []; $object1 = new stdClass(); $object1->id = 1; $object1->value = 'Object #1'; $storage->attach($object1); $array[$object1->id] = $object1; foreach($storage as $x) var_dump($x->value); // Object #1 foreach($array as $x) var_dump($x->value); // Object #1 $object2 = new stdClass(); $object2->id = 1; $object2->value = 'Object #2'; $array[$object2->id] = $object2; $storage->attach($object2); foreach($storage as $x) var_dump($x->value); // Object #1 foreach($array as $x) var_dump($x->value); // Object #2
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 18, Position 2 = 24
Branch analysis from position: 18
2 jumps found. (Code = 78) Position 1 = 19, Position 2 = 24
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
Branch analysis from position: 24
2 jumps found. (Code = 77) Position 1 = 26, Position 2 = 32
Branch analysis from position: 26
2 jumps found. (Code = 78) Position 1 = 27, Position 2 = 32
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
Branch analysis from position: 32
2 jumps found. (Code = 77) Position 1 = 47, Position 2 = 53
Branch analysis from position: 47
2 jumps found. (Code = 78) Position 1 = 48, Position 2 = 53
Branch analysis from position: 48
1 jumps found. (Code = 42) Position 1 = 47
Branch analysis from position: 47
Branch analysis from position: 53
2 jumps found. (Code = 77) Position 1 = 55, Position 2 = 61
Branch analysis from position: 55
2 jumps found. (Code = 78) Position 1 = 56, Position 2 = 61
Branch analysis from position: 56
1 jumps found. (Code = 42) Position 1 = 55
Branch analysis from position: 55
Branch analysis from position: 61
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 61
Branch analysis from position: 53
Branch analysis from position: 32
Branch analysis from position: 24
filename:       /in/i1v7q
function name:  (null)
number of ops:  63
compiled vars:  !0 = $storage, !1 = $array, !2 = $object1, !3 = $x, !4 = $object2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   NEW                                              $5      'IdObjectStorage'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $5
          3        ASSIGN                                                   !1, <array>
    9     4        NEW                                              $9      'stdClass'
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !2, $9
          7        ASSIGN_OBJ                                               !2, 'id'
          8        OP_DATA                                                  1
          9        ASSIGN_OBJ                                               !2, 'value'
         10        OP_DATA                                                  'Object+%231'
   10    11        INIT_METHOD_CALL                                         !0, 'attach'
         12        SEND_VAR_EX                                              !2
         13        DO_FCALL                                      0          
   11    14        FETCH_OBJ_R                                      ~15     !2, 'id'
         15        ASSIGN_DIM                                               !1, ~15
         16        OP_DATA                                                  !2
   13    17      > FE_RESET_R                                       $17     !0, ->24
         18    > > FE_FETCH_R                                               $17, !3, ->24
         19    >   INIT_FCALL                                               'var_dump'
         20        FETCH_OBJ_R                                      ~18     !3, 'value'
         21        SEND_VAL                                                 ~18
         22        DO_ICALL                                                 
         23      > JMP                                                      ->18
         24    >   FE_FREE                                                  $17
   14    25      > FE_RESET_R                                       $20     !1, ->32
         26    > > FE_FETCH_R                                               $20, !3, ->32
         27    >   INIT_FCALL                                               'var_dump'
         28        FETCH_OBJ_R                                      ~21     !3, 'value'
         29        SEND_VAL                                                 ~21
         30        DO_ICALL                                                 
         31      > JMP                                                      ->26
         32    >   FE_FREE                                                  $20
   16    33        NEW                                              $23     'stdClass'
         34        DO_FCALL                                      0          
         35        ASSIGN                                                   !4, $23
         36        ASSIGN_OBJ                                               !4, 'id'
         37        OP_DATA                                                  1
         38        ASSIGN_OBJ                                               !4, 'value'
         39        OP_DATA                                                  'Object+%232'
   17    40        FETCH_OBJ_R                                      ~28     !4, 'id'
         41        ASSIGN_DIM                                               !1, ~28
         42        OP_DATA                                                  !4
   18    43        INIT_METHOD_CALL                                         !0, 'attach'
         44        SEND_VAR_EX                                              !4
         45        DO_FCALL                                      0          
   20    46      > FE_RESET_R                                       $31     !0, ->53
         47    > > FE_FETCH_R                                               $31, !3, ->53
         48    >   INIT_FCALL                                               'var_dump'
         49        FETCH_OBJ_R                                      ~32     !3, 'value'
         50        SEND_VAL                                                 ~32
         51        DO_ICALL                                                 
         52      > JMP                                                      ->47
         53    >   FE_FREE                                                  $31
   21    54      > FE_RESET_R                                       $34     !1, ->61
         55    > > FE_FETCH_R                                               $34, !3, ->61
         56    >   INIT_FCALL                                               'var_dump'
         57        FETCH_OBJ_R                                      ~35     !3, 'value'
         58        SEND_VAL                                                 ~35
         59        DO_ICALL                                                 
         60      > JMP                                                      ->55
         61    >   FE_FREE                                                  $34
         62      > RETURN                                                   1

Class IdObjectStorage:
Function gethash:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/i1v7q
function name:  getHash
number of ops:  5
compiled vars:  !0 = $object
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
          1        FETCH_OBJ_R                                      ~1      !0, 'id'
          2        CAST                                          6  ~2      ~1
          3      > RETURN                                                   ~2
          4*     > RETURN                                                   null

End of function gethash

End of class IdObjectStorage.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
130.17 ms | 1003 KiB | 14 Q