rfc:uuid
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
rfc:uuid [2017/05/27 22:06] – Typo fleshgrinder | rfc:uuid [2017/09/22 13:28] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 3: | Line 3: | ||
* Date: 2017-05-25 | * Date: 2017-05-25 | ||
* Author: Richard Fussenegger, | * Author: Richard Fussenegger, | ||
- | * Status: | + | * Status: |
* First Published at: http:// | * First Published at: http:// | ||
Line 9: | Line 9: | ||
Universally Unique Identifiers (UUIDs, also known as Globally Unique Identifiers [GUIDs]) are 128 bit integers that guarantee uniqueness across space and time. PHP currently provides the '' | Universally Unique Identifiers (UUIDs, also known as Globally Unique Identifiers [GUIDs]) are 128 bit integers that guarantee uniqueness across space and time. PHP currently provides the '' | ||
- | UUIDs are defined and standardized in [[https:// | + | UUIDs are defined and standardized in [[https:// |
Most high-level programming languages provide support for UUIDs out-of-the-box. The following is a list of widely used languages and other software that provides support for UUIDs out-of-the-box: | Most high-level programming languages provide support for UUIDs out-of-the-box. The following is a list of widely used languages and other software that provides support for UUIDs out-of-the-box: | ||
Line 41: | Line 41: | ||
==== Why C? ==== | ==== Why C? ==== | ||
There is no reason why this should be implemented in C. One could argue that it is faster, which it probably is, but this is a weak argument. This RFC would propose the inclusion of UUIDs implemented in PHP if shipping of PHP code as part of the standard module of PHP would be possible. However, there is a C API included that allows other PHP modules to utilize UUIDs. | There is no reason why this should be implemented in C. One could argue that it is faster, which it probably is, but this is a weak argument. This RFC would propose the inclusion of UUIDs implemented in PHP if shipping of PHP code as part of the standard module of PHP would be possible. However, there is a C API included that allows other PHP modules to utilize UUIDs. | ||
- | |||
- | < | ||
- | |||
- | <code c> | ||
- | PHPAPI extern zend_class_entry *php_ce_UUID; | ||
- | PHPAPI extern zend_class_entry *php_ce_UUIDParseException; | ||
- | |||
- | PHPAPI typedef uint8_t php_uuid[16]; | ||
- | PHPAPI typedef char php_uuid_hex[33]; | ||
- | PHPAPI typedef char php_uuid_string[37]; | ||
- | |||
- | PHPAPI const uint8_t PHP_UUID_LEN = 16; | ||
- | PHPAPI const uint8_t PHP_UUID_HEX_LEN = 32; | ||
- | PHPAPI const uint8_t PHP_UUID_STRING_LEN = 36; | ||
- | |||
- | PHPAPI extern const php_uuid PHP_UUID_NAMESPACE_DNS; | ||
- | PHPAPI extern const php_uuid PHP_UUID_NAMESPACE_OID; | ||
- | PHPAPI extern const php_uuid PHP_UUID_NAMESPACE_URL; | ||
- | PHPAPI extern const php_uuid PHP_UUID_NAMESPACE_X500; | ||
- | PHPAPI extern const php_uuid PHP_UUID_NIL; | ||
- | |||
- | PHPAPI typedef enum php_uuid_variant { | ||
- | PHP_UUID_VARIANT_NCS | ||
- | PHP_UUID_VARIANT_RFC4122 | ||
- | PHP_UUID_VARIANT_MICROSOFT | ||
- | PHP_UUID_VARIANT_FUTURE_RESERVED = 3, /* 0b111 */ | ||
- | } php_uuid_variant; | ||
- | |||
- | PHPAPI const uint8_t PHP_UUID_VERSION_1_TIME_BASED | ||
- | PHPAPI const uint8_t PHP_UUID_VERSION_2_DCE_SECURITY | ||
- | PHPAPI const uint8_t PHP_UUID_VERSION_3_NAME_BASED_MD5 | ||
- | PHPAPI const uint8_t PHP_UUID_VERSION_4_RANDOM | ||
- | PHPAPI const uint8_t PHP_UUID_VERSION_5_NAME_BASED_SHA1 = 5; | ||
- | |||
- | PHPAPI int php_uuid_parse(php_uuid *uuid, const char *input, const size_t input_len, const zend_bool throw); | ||
- | #define php_uuid_parse_silent(uuid, | ||
- | #define php_uuid_parse_throw(uuid, | ||
- | |||
- | PHPAPI void php_uuid_create_v3(php_uuid *uuid, const php_uuid *namespace, const char *name, const size_t name_len); | ||
- | |||
- | PHPAPI int php_uuid_create_v4(php_uuid *uuid, const zend_bool throw); | ||
- | #define php_uuid_create_v4_silent(uuid) php_uuid_create_v4(uuid, | ||
- | #define php_uuid_create_v4_throw(uuid) php_uuid_create_v4(uuid, | ||
- | |||
- | PHPAPI void php_uuid_create_v5(php_uuid *uuid, const php_uuid *namespace, const char *name, const size_t name_len); | ||
- | |||
- | PHPAPI zend_always_inline const php_uuid_variant php_uuid_get_variant(const php_uuid uuid); | ||
- | |||
- | PHPAPI zend_always_inline const uint8_t php_uuid_get_version(const php_uuid uuid); | ||
- | |||
- | PHPAPI zend_always_inline const int php_uuid_is_nil(const php_uuid uuid); | ||
- | |||
- | PHPAPI zend_always_inline void php_uuid_to_hex(php_uuid_hex *buffer, const php_uuid uuid); | ||
- | |||
- | PHPAPI zend_always_inline void php_uuid_to_string(php_uuid_string *buffer, const php_uuid uuid); | ||
- | |||
- | </ | ||
=== Why not PECL UUID? === | === Why not PECL UUID? === | ||
Line 108: | Line 51: | ||
The implementation consists of two new final classes in the global namespace. Supported generation algorithms are version 3, 4, and 5. Version 3 is provided for backwards compatibility with existing UUID implementations, | The implementation consists of two new final classes in the global namespace. Supported generation algorithms are version 3, 4, and 5. Version 3 is provided for backwards compatibility with existing UUID implementations, | ||
- | < | + | < |
<code php> | <code php> | ||
Line 166: | Line 109: | ||
</ | </ | ||
- | < | + | < |
<code php> | <code php> | ||
Line 196: | Line 139: | ||
Leading whitespace (spaces '' | Leading whitespace (spaces '' | ||
- | A '' | + | A '' |
The named '' | The named '' | ||
Line 226: | Line 169: | ||
===== Backward Incompatible Changes ===== | ===== Backward Incompatible Changes ===== | ||
- | Both '' | + | Both '' |
===== Proposed PHP Version(s) ===== | ===== Proposed PHP Version(s) ===== | ||
- | Next PHP 7.x | + | 7.3 |
===== RFC Impact ===== | ===== RFC Impact ===== | ||
Line 248: | Line 191: | ||
===== Open Issues ===== | ===== Open Issues ===== | ||
- | ==== Namespace ==== | + | None |
- | The discussion about namespace in PHP core is on ongoing dispute. This highly self-contained component could easily be provided from an internal namespace and thus lay the grounds for other things to come. This would require additional discussion, but possible namespaces in alphabetical order are ('' | + | |
- | + | ||
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | + | ||
- | Other variations, based on the premise that the reserved '' | + | |
- | + | ||
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | + | ||
- | ==== Doxygen Documentation ==== | + | |
- | The provided implementation uses [[http:// | + | |
===== Unaffected PHP Functionality ===== | ===== Unaffected PHP Functionality ===== | ||
Line 277: | Line 201: | ||
===== Proposed Voting Choices ===== | ===== Proposed Voting Choices ===== | ||
- | Simple 50%+1 majority vote. | + | Simple 50%+1 majority vote that ends on September 20, 2017. |
+ | |||
+ | <doodle title=" | ||
+ | * Yes | ||
+ | * No | ||
+ | </ | ||
===== Patches and Tests ===== | ===== Patches and Tests ===== | ||
Line 295: | Line 224: | ||
* [[https:// | * [[https:// | ||
* [[https:// | * [[https:// | ||
+ | * [[https:// | ||
===== Rejected Features ===== | ===== Rejected Features ===== | ||
- | None so far. | + | * Doxygen Documentation ([[https:// |
+ | * Namespaces ([[https:// |
rfc/uuid.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1