Skip to content

Add notice that output of spl_object_hash() should only be compared type safe #2406

Closed
@dev-maniac

Description

@dev-maniac

With pull request php/php-src#7010 (PHP 8.1, I think) the result format of spl_object_hash() changed.
The hash is now much more simple and can be something like 0000000000000e600000000000000000, which PHP will interpret as number 0 (exponent).
We stumbled across this, because we used the object hash to check, if we already processed an object. We stored the hash in an array and checked with a simple in_array(), if array contains hash. But with PHP 8.2 this suddenly returned true for some objects which lead to some "interesting" side effects...

So I think it would be worthwhile to add a notice in documentation, that the hash should always be compared type-safe.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions