3v4l.org

run code in 300+ PHP versions simultaneously
<?php class User{ public $id; function __construct($id) { $this->id = $id; } } class UserStorage extends SPLObjectStorage{ public function getHash($obj){ return $obj->id; } } $us = new UserStorage(); $user1 = new User(1); $user2 = new User(2); $us->attach($user1); $us->attach($user2); $me = new User(2); // the following would normally fail since they are two separate objects // but it works now with our extended getHash() var_dump($us->contains($me));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YnvsU
function name:  (null)
number of ops:  28
compiled vars:  !0 = $us, !1 = $user1, !2 = $user2, !3 = $me
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   NEW                                              $4      'UserStorage'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $4
   20     3        NEW                                              $7      'User'
          4        SEND_VAL_EX                                              1
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !1, $7
   21     7        NEW                                              $10     'User'
          8        SEND_VAL_EX                                              2
          9        DO_FCALL                                      0          
         10        ASSIGN                                                   !2, $10
   23    11        INIT_METHOD_CALL                                         !0, 'attach'
         12        SEND_VAR_EX                                              !1
         13        DO_FCALL                                      0          
   24    14        INIT_METHOD_CALL                                         !0, 'attach'
         15        SEND_VAR_EX                                              !2
         16        DO_FCALL                                      0          
   26    17        NEW                                              $15     'User'
         18        SEND_VAL_EX                                              2
         19        DO_FCALL                                      0          
         20        ASSIGN                                                   !3, $15
   30    21        INIT_FCALL                                               'var_dump'
         22        INIT_METHOD_CALL                                         !0, 'contains'
         23        SEND_VAR_EX                                              !3
         24        DO_FCALL                                      0  $18     
         25        SEND_VAR                                                 $18
         26        DO_ICALL                                                 
         27      > RETURN                                                   1

Class User:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YnvsU
function name:  __construct
number of ops:  4
compiled vars:  !0 = $id
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    8     1        ASSIGN_OBJ                                               'id'
          2        OP_DATA                                                  !0
    9     3      > RETURN                                                   null

End of function __construct

End of class User.

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

End of function gethash

End of class UserStorage.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
145.54 ms | 1400 KiB | 15 Q