> Hi Internals.
>
> Random Extension 5.x has been accepted by a vote of 20(+1)/0. (I made a
> mistake in timing the closing of the vote and thus received one more vote)
> Therefore, voting on the Random Extension Improvement RFC will begin on
> 2022-07-02 as scheduled.
>
> Please check the RFC. This is the last chance to improve the implementation.
>
> https://wiki.php.net/rfc/random_extension_improvement

Hi,

I just realized a little thing: in the array_rand() example, for
$beforeSingle, it would probably be "more realistic" to omit `, 1`
(which is already the default for $num).

Note: for `Randomizer::pickArrayKeys(array $array, int $num): array`,
it makes sense that $num does *not* have a default value (1 would be
"weird" because the method always returns a *list of keys*, and
count($array) [via null] would be "useless" because keys are returned
*in their original order* [so it would make the method equivalent to
array_keys($array) by default]),
and that's probably a good thing (it forces to update the call by
adding an explicit `, 1` argument and reminds to add a `[0]` or
similar on the returned value).

An alternative design would be `Randomizer::pickArrayKey(array
$array): int|string`, but migrating existing uses with $num != 1 would
be harder, so probably not better.

Regards,

--
Guilliam Xavier

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to