Re: [VOTE] Random Extension Improvement
| From: | Claude Pache | Date: | Thu, 14 Jul 2022 07:13:36 +0000 |
| Subject: | Re: [VOTE] Random Extension Improvement | ||
| References: | 1 2 3 4 5 6 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-118264@lists.php.net to get a copy of this message | ||
> Le 14 juil. 2022 à 06:32, Guilliam Xavier <guilliam.xavier@gmail.com> a écrit :
>
> On Thursday, July 14, 2022, Go Kudo <g-kudo@colopl.co.jp> wrote:
>
>> 2022年7月13日(水) 1:10 Tim Düsterhus <tim@bastelstu.be>:
>>
>>> Hi
>>>
>>> On 7/12/22 18:04, Tim Düsterhus wrote:
>>>> I also think that both '$string' and '$binary' are appropriate
>>>> parameter
>>>> names in this case, so particular preference from my side.
>>>
>>> Sorry for the follow-up, there's two mistakes in that sentence. It
>>> should read:
>>>
>>> I also think that both '$string' and **'$bytes'** are appropriate
>>> parameter names in this case, so **no** particular preference from my
>>> side.
>>>
>>> Best regards
>>> Tim Düsterhus
>>>
>>
>> Hi
>>
>> I agree with you. I will change the parameter name from
>>
$string to
>> $bytes as I don't see any problem.
>>
>> I will try to explain the changes more rigorously in future proposals.
>> Thank you.
>>
>> Regards,
>> Go Kudo
>>
>
> Hi,
>
> I was waiting for more opinions but... so here's mine:
>
> I would prefer to keep "$string", as [that's how I read the RFCs, and] when
> calling e.g. shuffleBytes('foobar') I don't feel like I'm passing
> "bytes"
> (or "a binary") but a string (to be shuffled byte-wise rather than
> character-wise or codepoint-wise, but that's from the function, not the
> argument)...
> Granted, not compelling, and probably won't matter in practice, but hey ;)
>
> Regards
>
> PS: sent from mobile
>
>
> --
> Guilliam Xavier
I agree with Guilliam: this function is about «shuffling the bytes of the given string» (as
opposed to, say, «array of ints»)
As precedent, there are bin2hex($string) and md5($string), which are
unambiguously working with bytes from data given in the form of string, where «string» is a PHP
type, which can hold data that is not necessarily UTF-8-encoded or Shift-JIS-encoded text.
—Claude