8000 [String] allow passing a string of custom characters to ByteString::fromRandom by azjezz · Pull Request #36471 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[String] allow passing a string of custom characters to ByteString::fromRandom #36471

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

Merged
merged 1 commit into from
May 5, 2020

Conversation

azjezz
Copy link
Contributor
@azjezz azjezz commented Apr 16, 2020
Q A
Branch? master
Bug fix? no
New feature? yes/
Deprecations? no
License MIT
Doc PR symfony/symfony-docs#...

@azjezz azjezz force-pushed the rand-string-chars branch from 632963b to 184ee9c Compare April 16, 2020 18:22
@nicolas-grekas nicolas-grekas added this to the next milestone Apr 16, 2020
@azjezz azjezz force-pushed the rand-string-chars branch 3 times, most recently from 669bb22 to 9f8878f Compare April 16, 2020 18:31
Copy link
Member
@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, here are some early random comments :)

// Worst case, it is 2^k + 1, which means we need (k+1) bits and we
// have around a 50% chance of missing as k gets larger
if ($index < $alphabet_size) {
$ret .= $alphabet[$index];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

funny idea: move the function on the base class and allow "characters" to be either code points and/or grapheme clusters, depending on what chunk() returns

@azjezz azjezz force-pushed the rand-string-chars branch from 9f8878f to b4007b7 Compare May 3, 2020 08:04
@nicolas-grekas nicolas-grekas modified the milestones: next, 5.1 May 4, 2020
@azjezz azjezz force-pushed the rand-string-chars branch from b4007b7 to 5d15c0b Compare May 4, 2020 22:13
Copy link
Member
@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's go and improve during the betas if there is something to improve

@fabpot
Copy link
Member
fabpot commented May 5, 2020

Thank you @azjezz.

< 9166 /div>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0