There was a proposal back in 2015 to implement a function spl_object_id(object $o) : int`, which directly returns the object handle (similar to `spl_object_hash`, but as an integer, not a string). I'm interested in finishing implementing spl_object_id for php 7.2
I already have working code implementing spl_object_id() at https://github.com/TysonAndre/php-src/pull/1 The implementation XORs the object handle with the exact same random bits that `spl_object_hash` would. Previous emails from 2015 can be seen here: - https://marc.info/?t=143835274500003&r=1&w=2 Previous comment by a PHP maintainer in support of `spl_object_id()` - https://marc.info/?l=php-internals&m=143837339210596&w=2 I'm unsure if an RFC is necessary. I have two pending questions. - Can two objects can have the same object id but different object handlers? (e.g. iterators of some built in classes?) I'm not familiar enough with PHP's history to be sure. - Can the the largest object handle be larger than the size of `zend_long` in 32-bit systems? Example places where this would be useful: 1. https://marc.info/?l=php-internals&m=143849841618494&w=2 2. I also recently wanted to track a large number of (cloneable) small sets of objects in an application that sometimes used a lot of memory, and the fact that arrays support copy on write helped save memory relative to SplObjectHash if arrays and integer keys were used. See https://github.com/etsy/phan/pull/729#issuecomment-299289378 - Tyson Andre (tandre) -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php