Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:87521 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 79732 invoked from network); 2 Aug 2015 17:09:23 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Aug 2015 17:09:23 -0000 Authentication-Results: pb1.pair.com header.from=derick@php.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=derick@php.net; spf=unknown; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 82.113.146.227 as permitted sender) X-PHP-List-Original-Sender: derick@php.net X-Host-Fingerprint: 82.113.146.227 xdebug.org Linux 2.6 Received: from [82.113.146.227] ([82.113.146.227:40026] helo=xdebug.org) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E3/E2-55344-0CE4EB55 for ; Sun, 02 Aug 2015 13:09:20 -0400 Received: from localhost (localhost [IPv6:::1]) by xdebug.org (Postfix) with ESMTPS id 327F810C209; Sun, 2 Aug 2015 18:09:17 +0100 (BST) Date: Sun, 2 Aug 2015 18:09:16 +0100 (BST) X-X-Sender: derick@whisky.home.derickrethans.nl To: Julien Pauli cc: PHP Internals In-Reply-To: Message-ID: References: User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Subject: Re: [PHP-DEV] Exposing object handles to userland From: derick@php.net (Derick Rethans) On Fri, 31 Jul 2015, Julien Pauli wrote: > Hi people. > > I've been pinged many times to add a new spl_object_id() function to PHP, > that would return the internal object handle of an object. > > Today, spl_object_hash() partially allows that, but adds many randomness to > the result, which is not very cool to use later (why does it even add > randomness ?). > > There has been topics about this subject. > For example, at http://marc.info/?l=php-internals&m=141814350920452&w=2 > > > Beeing able to get the object handle back in PHP userland would ease many > tools, mainly debug-oriented tools. > I know PHPUnit, Symfony and many big projects today make use of > spl_object_hash() to identify objects. > > I also know people that print_r($an_object) and parse the output just to > extract the object handle from there... Crazy isn't it ? > Why couldn't we help those people by simply adding a new function that does > the job ? You realize that these object handles aren't particularly stable? The same object ID can be reused: derick@whisky:/tmp $ cat objid.php