Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:79500 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 89604 invoked from network); 9 Dec 2014 14:40:15 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 Dec 2014 14:40:15 -0000 Authentication-Results: pb1.pair.com smtp.mail=nicolas.grekas@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=nicolas.grekas@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.49 as permitted sender) X-PHP-List-Original-Sender: nicolas.grekas@gmail.com X-Host-Fingerprint: 209.85.215.49 mail-la0-f49.google.com Received: from [209.85.215.49] ([209.85.215.49:59152] helo=mail-la0-f49.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 9B/00-23416-FC907845 for ; Tue, 09 Dec 2014 09:40:15 -0500 Received: by mail-la0-f49.google.com with SMTP id hs14so622031lab.36 for ; Tue, 09 Dec 2014 06:40:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=oOw+FNAt05JP5sWJwoKrmtJpQKmuZz29dyklYqFahx0=; b=L48k5hGhrrrgWQsUeLh2rId4Gh+P8YagOJJzeZqmc5J2Ge6JkIQVyNsq1zQ7SdzHf8 8h+OxaEmql85PWOqMHulxhEwB0JXMkSYiJk4BwYgdVcAXkpJZA5Xm2TU9dGJvEMoIiJX 7PrZH1yABmSpIPTPz8u1VS7/AN1WPHUavH8zJ6Bgpto97eFL1AmF32Y/rqfRWtxvt6m/ 2/y8w1VMBmz3L/9Yu9IDThHJmh+ZYAZjj0kEjyxtA6eQ/xPuMMaHYflaGUNPzcIpdWEX JG9uq7BpdqFvuj0U7INODCjcmwq4Z7fEQZ9BiO4w5MTRpNY+eR0Jco6edZQc0Tk5ikMS Zyyw== X-Received: by 10.112.147.199 with SMTP id tm7mr22574681lbb.92.1418136011733; Tue, 09 Dec 2014 06:40:11 -0800 (PST) MIME-Version: 1.0 Sender: nicolas.grekas@gmail.com Received: by 10.152.110.230 with HTTP; Tue, 9 Dec 2014 06:39:50 -0800 (PST) In-Reply-To: <5486DA89.3090605@gmail.com> References: <5486DA89.3090605@gmail.com> Date: Tue, 9 Dec 2014 15:39:50 +0100 X-Google-Sender-Auth: Xolu3wuGMwZCV_CQnc__7fJ0MQo Message-ID: To: Rowan Collins Cc: "internals@lists.php.net" Content-Type: multipart/alternative; boundary=047d7b3a893c39017d0509c9852f Subject: Re: [PHP-DEV] New function: spl_object_id() or spl_object_handle() From: nicolas.grekas+php@gmail.com (Nicolas Grekas) --047d7b3a893c39017d0509c9852f Content-Type: text/plain; charset=UTF-8 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. 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. Regards, Nicolas --047d7b3a893c39017d0509c9852f--