randomFloat() does not always return a float
Author: localheinzCreated Mar 19, 2020Updated Sep 18, 2020
Labelsbug
Summary
When using $faker->randomFloat(), sometimes an int is returned.
Versions
| Version | |
|---|---|
| PHP | any |
fzaninotto/faker |
1.9.2 |
Self-enclosed code snippet for reproduction
$faker = Faker\Factory::create();
$value = $faker->randomFloat();
assert(is_float($value));Expected output
No issues in all cases.
Actual output
Fails randomly.
This can likely be solved by using appropriate return type declarations in next or casting the value to a float before returning it.
Source: fzaninotto/Faker