File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -196,6 +196,29 @@ impl ZendObject {
196
196
T :: from_zend_object ( self )
197
197
}
198
198
199
+ /// Returns an unique identifier for the object.
200
+ ///
201
+ /// The id is guaranteed to be unique for the lifetime of the object.
202
+ /// Once the object is destroyed, it may be reused for other objects.
203
+ /// This is equivalent to calling the [`spl_object_id`] PHP function.
204
+ ///
205
+ /// [`spl_object_id`]: https://www.php.net/manual/function.spl-object-id
206
+ #[ inline]
207
+ pub fn get_id ( & self ) -> u32 {
208
+ self . handle
209
+ }
210
+
211
+ /// Computes an unique hash for the object.
212
+ ///
213
+ /// The hash is guaranteed to be unique for the lifetime of the object.
214
+ /// Once the object is destroyed, it may be reused for other objects.
215
+ /// This is equivalent to calling the [`spl_object_hash`] PHP function.
216
+ ///
217
+ /// [`spl_object_hash`]: https://www.php.net/manual/function.spl-object-hash.php
218
+ pub fn hash ( & self ) -> String {
219
+ format ! ( "{:016x}0000000000000000" , self . handle)
220
+ }
221
+
199
222
/// Attempts to retrieve a reference to the object handlers.
200
223
#[ inline]
201
224
unsafe fn handlers ( & self ) -> Result < & ZendObjectHandlers > {
You can’t perform that action at this time.
0 commit comments