Skip to content

Conversation

zeriyoshi
Copy link
Contributor

@zeriyoshi zeriyoshi commented Jan 2, 2021

Implementation for RFCs: https://wiki.php.net/rfc/object_scope_prng

Overview:

  • Provides PHP with a RNG implementation of object scope.
  • Functions that use the existing internal MT RNG will now accept a new $rng argument.
    • shuffle()
    • str_shuffle()
    • array_rand()
  • The following are implemented as built-in RNGs in this PR.
    • XorShift128+ (Modern PRNG)RNG\XorShift128Plus
    • MT19937 (PHP's internal MT compatibile) RNG\MT19937
    • OS (OS provided RNG generator) RNG\OS
  • XorShift128Plus and MT19937 are serializable and can store state as a string.
  • A few functions will be added
    • rng_bytes(): Generates a string of bytes of the specified length using RNG.
    • rng_int(): Generate a number using RNG, similar random_int() .
    • rng_next(): Generates 32bit raw random number using RNG.
    • rng_next64(): Generates 64bit raw random number using RNG.

Checklist:

  • Check works on 64bit / 32bit architectures
  • Check works on Windows
  • Check correctly implemented __serialize() and __unserialize()
  • Implement MT19973
  • Add consistency tests 64bit / 32bit environments

@zeriyoshi zeriyoshi force-pushed the object_scope_rng branch 3 times, most recently from cd4cfdb to df8d9c9 Compare January 16, 2021 18:16
@zeriyoshi zeriyoshi changed the title WIP: Object-scoped RNG implementation Object-scoped RNG implementation Jan 17, 2021
@zeriyoshi zeriyoshi changed the title Object-scoped RNG implementation [RFC] Object-scoped RNG implementation Jan 17, 2021
@zeriyoshi zeriyoshi force-pushed the object_scope_rng branch 7 times, most recently from 84977a3 to f9695a5 Compare January 25, 2021 01:02
@cmb69 cmb69 added the RFC label Mar 10, 2021
@zeriyoshi zeriyoshi force-pushed the object_scope_rng branch 3 times, most recently from ae388a9 to dcad402 Compare March 23, 2021 13:35
@zeriyoshi zeriyoshi force-pushed the object_scope_rng branch 2 times, most recently from 9aa0e44 to 03e7ce3 Compare April 1, 2021 04:30
@zeriyoshi
Copy link
Contributor Author

This RFC is declined. close it.
new RFC: https://wiki.php.net/rfc/rng_extension

@zeriyoshi zeriyoshi closed this May 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants