/runkit_object_id

C module, similar to spl_object_hash but returning an int instead. The safest function in runkit.

Primary LanguageCOtherNOASSERTION

runkit_object_id (by the runkit7 project)

(Also provides a native implementation of spl_object_id)

For the safest function in runkit(7). This implements runkit_object_id() : ?int, which is similar to spl_object_hash() : string, but returns an integer instead of a string. The runkit_object_id() is faster if you need to take the ids of a large number of objects, and avoids the memory overhead of storing extra strings.

By default, this provides a native alias (for PHP <= 7.1) for spl_object_id, which is a native part of PHP 7.2. Add --enable-runkit-spl_object-id=no to the configure options to disable this.

Both runkit_object_id($obj) and spl_object_hash($obj) return identifiers that are unique for the lifetime of the object. After the object is garbage collected, that identifier can/will be used again.

Supports php 5.3+ and php 7.0+.

See runkit_object_id-api.php for function stubs, and an alternate (slower) pure PHP implementation.

Build Status Build Status (Windows)

Motivation

An integer object id has been a requested function for a while. spl_object_id() is getting added to PHP 7.2, but there's nothing for php <= 7.1

Installation

Similar to runkit7 installation steps, but using this repo instead.

If runkit (extension=runkit.so) is installed and enabled, then disable this module.