Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:77617 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 50356 invoked from network); 25 Sep 2014 09:26:20 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Sep 2014 09:26:20 -0000 Authentication-Results: pb1.pair.com header.from=leight@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=leight@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.170 as permitted sender) X-PHP-List-Original-Sender: leight@gmail.com X-Host-Fingerprint: 74.125.82.170 mail-we0-f170.google.com Received: from [74.125.82.170] ([74.125.82.170:34846] helo=mail-we0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 94/80-45824-BBFD3245 for ; Thu, 25 Sep 2014 05:26:20 -0400 Received: by mail-we0-f170.google.com with SMTP id x48so6179461wes.1 for ; Thu, 25 Sep 2014 02:26:17 -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=H667WpfHvgM61qecseJhUESUv4nV8CXB+v9ym84VydE=; b=tj/ASx6QjU1ULdRCxihz26E8PMGYraz9IM6N6m2HTTfWHGAt0xn+gqCwmT/5g9Fmxm W7mSupGrv1uEzWNjqlURE56C/3GlLK0Rn4/p6GBy0BW8uugFb73RCsTpZLcLxm97liwH 2WKDW/yTB79BfPeMABUkandNS02Eh9sh+zpZAUJHRIzzFYtxz26V3zI0axiF20fjtHoa wdjO/RJawKUTEy+lHvo+aRcyg8HSprYKY2oRcP4Tuw24lQaQb2FikLkGryxkkX2tVSLO yVNCKUzlui+yERKEnPrvXFhhRQediBiM808nGjcADA2dEtoVwsYu9E1z2WsN7Qvd/TRN 3FHA== MIME-Version: 1.0 X-Received: by 10.194.242.33 with SMTP id wn1mr1307384wjc.110.1411637176834; Thu, 25 Sep 2014 02:26:16 -0700 (PDT) Received: by 10.217.55.195 with HTTP; Thu, 25 Sep 2014 02:26:16 -0700 (PDT) In-Reply-To: <5423D096.9010508@lsces.co.uk> References: <1411561476.2303.4.camel@guybrush> <54232205.4020806@sugarcrm.com> <3E4C58C8-E816-4798-9D8F-2C7EFFA28438@ajf.me> <5423C701.807@lsces.co.uk> <5423D096.9010508@lsces.co.uk> Date: Thu, 25 Sep 2014 10:26:16 +0100 Message-ID: To: Lester Caine Cc: internals@lists.php.net Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] Invokation on __toString() for object used as array key From: leight@gmail.com (Leigh) On 25 September 2014 09:21, Lester Caine wrote: > > 'This function returns a unique identifier for the object.' > There is a mistaken view in some usage that that will be DIFFERENT for > different versions of the same object. Not sure who has that view. It's quite clearly documented, for the lifetime of an object, it will always have the same hash. > So what *IS* returned by spl_object_hash? > The UCN from 7 years ago flags that the identifier is only based on the > internal pointers to the object in memory and that the result is not > user friendly, but without digging into the code, the problems such as > the fact that re-use of the buffer space by a later object cached in the > same buffer may be the same as ID? Yes it is created using various internal pointers, and is about as user-friendly as any other kind of hash. It is possible to create a duplicate hash if you unset an object, force GC collection, and then create a new object which can occupy the same memory location. var_dump(spl_object_hash(new stdClass())); gc_collect_cycles(); var_dump(spl_object_hash(new stdClass())); This is a fairly unrealistic scenario, however Joe Watkins has developed a better hash method that doesn't have this flaw, I don't know if he ever intended to have it applied to core or not.