Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:79504 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 97908 invoked from network); 9 Dec 2014 15:36:35 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 Dec 2014 15:36:35 -0000 Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.176 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 209.85.212.176 mail-wi0-f176.google.com Received: from [209.85.212.176] ([209.85.212.176:51366] helo=mail-wi0-f176.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 17/A1-23416-10717845 for ; Tue, 09 Dec 2014 10:36:34 -0500 Received: by mail-wi0-f176.google.com with SMTP id ex7so8282646wid.3 for ; Tue, 09 Dec 2014 07:36:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type; bh=75uU7dY5e0MFVt0Y2pI6fKC5eCi9N8uJ9ZGtO/nUKwc=; b=HB2A76fe/YSzMCmKhYtxEf0IdLzNHd5djX9xJ7wdyVYQI5Ht3fvRrqgZiBc4O2aJHY EnyPOhyZWepFjf0IG/iiPFpK1rg4Tmiu2MbD5/UoNNH67K/7XyPs+jJuZLNkCZhEVHt4 XJL6dlqf/whaWL1MZgFrLcy2y0f8m+BAyxAejEV5FHhkS9uoEjs/CMmFOUaxC3ilHYHQ e/stpzhKTZzDvjCW2wXwB7ivpcvTSzIlWRhtRrAMOA1pclTcoslVQxpesp2nNKgGIBeo T2FkpbUElVH7NvcyK4EM+BCAWofoXo7hZF5R7Sb690mNK9LOJumNGmzVmTxbQd39Ce/D eZ4g== X-Received: by 10.194.6.7 with SMTP id w7mr5828003wjw.25.1418139390424; Tue, 09 Dec 2014 07:36:30 -0800 (PST) Received: from [192.168.0.148] ([62.189.198.114]) by mx.google.com with ESMTPSA id h14sm2678296wic.8.2014.12.09.07.36.29 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Dec 2014 07:36:29 -0800 (PST) Message-ID: <548716F7.4090007@gmail.com> Date: Tue, 09 Dec 2014 15:36:23 +0000 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 To: "internals@lists.php.net" References: <5486DA89.3090605@gmail.com> In-Reply-To: Content-Type: multipart/alternative; boundary="------------060000030400070908050603" Subject: Re: [PHP-DEV] New function: spl_object_id() or spl_object_handle() From: rowan.collins@gmail.com (Rowan Collins) --------------060000030400070908050603 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Nicolas Grekas wrote on 09/12/2014 14:39: > Hi Rowan, > > In order to get an object's id, I use a trick that works for now: > https://github.com/symfony/symfony/blob/2.6/src/Symfony/Component/VarDumper/Cloner/VarCloner.php#L258-L282 > > > This seems like a very elaborate piece of reverse engineering > > > Right, and I made the claim for this being a trick :) > > Still: the exact value is not what I'm most interested in you're right > (but it provides rought information about the number of objects > currently allocated which might be useful sometimes). > > The gain is displaying a shortest possible number. I could rehash > you're right, but then I'll have collisions. Both arguments > (short+unique number) are relevant when debugging/dumping. Yes, I think a version of spl_object_hash that was more human-readable would be a sensible move. IMHO, it would not be a BC break to completely change the output, since the documentation makes no promises about it, and reverse-engineered code like yours could just check PHP_VERSION. > > > https://github.com/symfony/symfony/tree/2.6/src/Symfony/Component/Debug/Resources/ext > > > The more interesting part of this is the refcount > > > That, plus the fact that it returns the value (instead of writing it > to php://output) > but other returned values are also important, especially zval_hash and > zval_isref that allow efficient tracking of hard references. Indeed. A non-function version of debug_zval_dump which could do this on any variable would be even better (if I read it right, your function only works on array members?) -- Rowan Collins [IMSoP] --------------060000030400070908050603--