Re: spl_object_hash documentation
| From: | Peter Cowburn | Date: | Sat, 07 Jun 2014 22:35:22 +0000 |
| Subject: | Re: spl_object_hash documentation | ||
| References: | 1 2 3 | Groups: | php.doc |
| Request: | Send a blank email to phpdoc+get-969384982@lists.php.net to get a copy of this message | ||
On 7 June 2014 18:32, Karoly Negyesi <karoly@negyesi.net> wrote:
> Well, OK. But then what can we put in? I sorta felt something being off
> otherwise I would've just went ahead.
>
Detailing the “lifetime” of the hash would be a good addition; clearly
stating that hashes are only unique for objects that exist at the time of
the function call. This should easily, and concisely, alleviate the key
problem of people assuming that the hash “represents an object uniquely for
the life of the script”.
Warning, in no uncertain terms, against the use of this function, is a
terrible idea. Particularly when using the FUD-like language added in the
patch.
I would advise against providing details of what exactly is used to make up
the hash, and mentioning things that are not considered for it.
Hope that helps!
>
> On Sat, Jun 7, 2014 at 12:29 PM, Hannes Magnusson <
> hannes.magnusson@gmail.com> wrote:
>
>> On Sat, Jun 7, 2014 at 9:42 AM, Karoly Negyesi <karoly@negyesi.net>
>> wrote:
>> > Hi,
>> >
>> > I have seen many bogus pieces of code which presume that
>> spl_object_hash is
>> > usable for anything; that it gives you a hash that represents an object
>> > uniquely for the life of the script. This is (not) obviously not true:
>> the
>> > hash gets reused and the hash does not depend on the properties and the
>> > values of the properties.
>> >
>> > I tried to ask for a review on IRC but the result was the sort of
>> > otherworldly discussion I am used to on PHP Internals only, not here.
>> >
>> > Anyways, I put the suggested changes on
>> http://privatepaste.com/95c871de6c .
>> > Suggestions welcome. Suggesting I am in idiot is not.
>>
>>
>> "Using this
>> + function for anything but the previous example will very likely lead to
>> + hard to debug problems and even data corruption."
>>
>> This is obviously not gonna be in the docs.
>>
>> -Hannes
>>
>
>