> 1. I'm still not a fan of exposing the algorithms as separate classes in PHP. Their names are confusing and I don't see how exposing them gives any benefits. I would prefer that, like in password_hash, let the user chose the algorithm using a constant then ask for seed as a second argument to Randomizer.
This may be useful if you are implementing a specific RNG in userland. It also gets quite complicated when trying to implement extensions that add corresponding algorithms. Since we're going all out, I thought it might be appropriate to use the OOP approach. What do you think? > 2. Why is there a getter on Randomizer for the source? Some Source objects are serializable and can store state, to take advantage of this feature. > 3. Why is the interface called source? I couldn't think of an appropriate name. Do you have any ideas? > 4. You have generateInt() twice. Wouldn't it be better to have it only once but make the arguments nullable or provide PHP_MIN_INT and PHP_MAX_INT as defaults? This is to maintain compatibility with the `mt_rand()` function. > 5. Why do we need to deprecate the old functions now? What's the rush? Keeping old implementations may lead to code being written that unintentionally relies on the PHPs global state. Deprecating them reduces the possibility that such code will be written anew. 2021年5月19日(水) 2:29 Kamil Tekiela <tekiela...@gmail.com>: > Hi Go Kudo, > > I think this proposal is much better than the one before. I believe we > need such functionality in PHP. > I have some questions I would like you to consider: > 1. I'm still not a fan of exposing the algorithms as separate classes in > PHP. Their names are confusing and I don't see how exposing them gives any > benefits. I would prefer that, like in password_hash, let the user chose > the algorithm using a constant then ask for seed as a second argument > to Randomizer. > 2. Why is there a getter on Randomizer for the source? > 3. Why is the interface called source? > 4. You have generateInt() twice. Wouldn't it be better to have it only > once but make the arguments nullable or provide PHP_MIN_INT and PHP_MAX_INT > as defaults? > 5. Why do we need to deprecate the old functions now? What's the rush? > > Regards, > Kamil >