Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:87445 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 74667 invoked from network); 31 Jul 2015 16:35:51 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 31 Jul 2015 16:35:51 -0000 Authentication-Results: pb1.pair.com smtp.mail=ircmaxell@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ircmaxell@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.217.180 as permitted sender) X-PHP-List-Original-Sender: ircmaxell@gmail.com X-Host-Fingerprint: 209.85.217.180 mail-lb0-f180.google.com Received: from [209.85.217.180] ([209.85.217.180:36276] helo=mail-lb0-f180.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id EE/15-47755-5E3ABB55 for ; Fri, 31 Jul 2015 12:35:50 -0400 Received: by lbbud7 with SMTP id ud7so45560131lbb.3 for ; Fri, 31 Jul 2015 09:35:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=IqTlR2L9ZMFk1uR5NwCtFabsxiYwDXLizWe2+DFlCxk=; b=F4GE/F5xQAEoVcRrAE3U4LH2Eoa9wQobhMJa8QvTvGm78TA4UgzOLCbFGB8tsOljK8 XL8MbSslqpU9eZZdoUKUySuCcZYLvKscWr0nNpIzikirj9ZlzHidlD9giO3TkBIVx9Fa 0Q2lSNcdgpdZ0r0s1tW5/A0X2pRG9pbTEcmEPDMxDZD7rAlJHGwzNnuEmTm4CtbVuq93 gmI+ASchTkMQbQRI73j7kBDA5c6Wrx4HB3jr2cConjUOB+h13+M5gle4WKS0wWNKXn30 x2heVSjLsKQHpbryrQbOAFZF41j9xs4hS2W5JY5bt0vTQfpSRrNyYVEXHavOxhnbC5v+ rSVw== MIME-Version: 1.0 X-Received: by 10.152.120.198 with SMTP id le6mr3977065lab.38.1438360545936; Fri, 31 Jul 2015 09:35:45 -0700 (PDT) Received: by 10.25.5.215 with HTTP; Fri, 31 Jul 2015 09:35:45 -0700 (PDT) In-Reply-To: References: Date: Fri, 31 Jul 2015 12:35:45 -0400 Message-ID: To: Julien Pauli Cc: PHP Internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] Exposing object handles to userland From: ircmaxell@gmail.com (Anthony Ferrara) Julien, On Fri, Jul 31, 2015 at 10:23 AM, 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 ? > > Thoughts ? > I'm not sure about the randomness to the handle, but the hash also includes the object handler pointer. So without the random, we'd be leaking information about the memory layout of the application. And for the record, I am cool with simply exposing the handle. Anthony