Closed pawel-winiecki closed 5 months ago
The change you highlighted is about using random_int
instead of mt_rand
. It is a fallback value so it should not used if faker is set.
I can't see a reason why it would not be set because of this PR though
Faker isn't set because of bundle definition: https://github.com/nelmio/alice/blob/main/src/Bridge/Symfony/Resources/config/generator/resolver/value.xml#L103 - there is no autowire and faker isn't set as argument directly. So before that PR fallback was used.
Faker isn't set because of bundle definition: https://github.com/nelmio/alice/blob/main/src/Bridge/Symfony/Resources/config/generator/resolver/value.xml#L103
Hmm that should be fixed; faker is injected in a few other services there is no reasons to not inject it here.
So before that PR fallback was used.
Sure but mt_rant()
doesn't depend on the seed either does it?
Either way I think it would be best to fix it by injecting faker, rather than relying on the fallback (which is mean to prevent it from failing, not really to care about reproducing the same results for the same seed)
I have a Symfony project which uses optional values in fixtures. Starting from 3.13.0 fixtures aren't the same between runs. It's caused by replacing
mt_rand
withrandom_int
: https://github.com/nelmio/alice/pull/1150/files#diff-6587e0a77728299b447611c29e4778427c1c3644a4c890e1ffab0a4ba931a2b9R103If
OptionalValueResolver
doesn't have set$faker
it will userandom_int
which isn't deterministic (doesn't use seed). Default Symfony bundle configuration doesn't set$faker
.I suppose that above change wasn't intentional. Am I right?