Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:87557 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 90410 invoked from network); 3 Aug 2015 07:20:42 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Aug 2015 07:20:42 -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.212.174 as permitted sender) X-PHP-List-Original-Sender: nicolas.grekas@gmail.com X-Host-Fingerprint: 209.85.212.174 mail-wi0-f174.google.com Received: from [209.85.212.174] ([209.85.212.174:33125] helo=mail-wi0-f174.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id EA/20-22506-9461FB55 for ; Mon, 03 Aug 2015 03:20:41 -0400 Received: by wicmv11 with SMTP id mv11so123296217wic.0 for ; Mon, 03 Aug 2015 00:20:38 -0700 (PDT) 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=UBZs4Maf+UDxcbbuTJURC/oVcdTRKEAm5Wz/VlInpV0=; b=Wv/YbXh8IOQeFx2FT7W6n8gz7sG5gMQlPHAl3WjuXSOJc3pIZwISAtY+JQ0Ouvpjju lIwIEjbtrHcBrndV+zYFb89NJtUf2y8qhZ/tvZRxd7Qg6vqA/dSPBPYOAUg8xNkg9g8s tR3UcADePev//ycikZplLi86P1ZDPWNKAkIRavp12ta9/GXYzBXVD55arcalQIO4M966 5SNjaknu92GDJmVs/+2mR8wLPneC1rJZtqS6qc4by4hUXRDsuAGEfDPPxRMuYduwPytc oXWL3sN/lUmDkkjP8ydkGWFIFxOb2ssNVqOqnJCHsb329J2M1R9m7qGmeI9s7H5HDOlq 8mMA== X-Received: by 10.181.25.234 with SMTP id it10mr30450609wid.41.1438586438208; Mon, 03 Aug 2015 00:20:38 -0700 (PDT) MIME-Version: 1.0 Sender: nicolas.grekas@gmail.com Received: by 10.27.172.10 with HTTP; Mon, 3 Aug 2015 00:20:18 -0700 (PDT) In-Reply-To: <55BE5B89.5080103@gmail.com> References: <024101d0cbaa$f864aa50$e92dfef0$@belski.net> <55BDBE25.5050104@gmail.com> <55BE5B89.5080103@gmail.com> Date: Mon, 3 Aug 2015 09:20:18 +0200 X-Google-Sender-Auth: KGUaeke5FpIzW5FCtde7iJGns2Y Message-ID: To: Rowan Collins Cc: "internals@lists.php.net" Content-Type: multipart/alternative; boundary=001a1136cbd8a0d311051c63011c Subject: Re: [PHP-DEV] Exposing object handles to userland From: nicolas.grekas+php@gmail.com (Nicolas Grekas) --001a1136cbd8a0d311051c63011c Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 2015-08-02 20:03 GMT+02:00 Rowan Collins : > On 02/08/2015 18:41, Bob Weinand wrote: > >> Some suspicious use of spl_object_hash() out there... >>> > >>> >>>> >> >>>> https://github.com/symfony/symfony/blob/master/src/Symfony/Component/V= arDumper/Cloner/VarCloner.php >>>> >>> > >>> >Not sure what this one does... but calculations with spl_object_hash() >>> >look very suspicious. >>> >> Actually, it's doing the right thing=E2=80=A6 calculating the value the = object id >> is xor'ed with (as we know that consecutively defined objects have >> consecutive ids). >> It's relying on the implementation of spl_object_hash() and will even >> continue to work when we remove that part of randomness as that value it= 's >> xor'ed with is then nothing else than 0. >> > > The right thing for what purpose? Why does it need that ID, rather than > the value that spl_object_hash() gave in the first place? Just to be > prettier to the user? > For the purpose of providing an id that humans can read and compare, to easily spot if two objects are identical or not. Try comparing two spl_object_hashes and you'll understand the need... The id as displayed by e.g. var_dump is not an implementation detail that leaks through it. It's really an important feature of the output. I learned that while implementing VarDumper (see link above), by user requests. Regards, Nicolas --001a1136cbd8a0d311051c63011c--