-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SimpleRandom constructor does not set seed value randomly if $seed is null #6
Comments
pointybeard
added a commit
to pointybeard-forks/ReverseRegex
that referenced
this issue
Nov 27, 2020
pointybeard
added a commit
to pointybeard-forks/ReverseRegex
that referenced
this issue
Nov 27, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Problem
Relates to
Random/SimpleRandom
class around line 40. The code looks like this:Notice that if
$seed
is eithernull
or0
, thatmt_rand()
is used to populate the seed value with a random value, however, the following line just overrides that with the contents of$seed
(eithernull
or0
).Current Behaviour
Calling
new SimpleRandom()
(i.e. without providing a seed value) will produce the same seed value everytime resulting in non-random value being generated (for me it's alwaysint(125)
).Expected Behaviour
Calling
new SimpleRandom()
will produce a random seed value for use internally.Solution
Modify the constructor to something like this to ensure the result of calling
mt_rand()
is propagated:The text was updated successfully, but these errors were encountered: