Skip to content

Commit 441959c

Browse files
committed
minor #13643 [String] Set characters to use in ByteString::fromRandom() (javiereguiluz)
This PR was merged into the master branch. Discussion ---------- [String] Set characters to use in ByteString::fromRandom() Fixes #13639. Commits ------- 11d5799 [String] Set characters to use in ByteString::fromRandom()
2 parents 0c48835 + 11d5799 commit 441959c

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

components/string.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,19 @@ There are also some specialized constructors::
133133

134134
// ByteString can create a random string of the given length
135135
$foo = ByteString::fromRandom(12);
136+
// by default, random strings use A-Za-z0-9 characters; you can restrict
137+
// the characters to use with the second optional argument
138+
$foo = ByteString::fromRandom(6, 'AEIOU0123456789');
139+
$foo = ByteString::fromRandom(10, 'qwertyuiop');
136140

137141
// CodePointString and UnicodeString can create a string from code points
138142
$foo = UnicodeString::fromCodePoints(0x928, 0x92E, 0x938, 0x94D, 0x924, 0x947);
139143
// equivalent to: $foo = new UnicodeString('नमस्ते');
140144

145+
.. versionadded:: 5.1
146+
147+
The second argument of ``ByteString::fromRandom()`` was introduced in Symfony 5.1.
148+
141149
Methods to Transform String Objects
142150
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
143151

0 commit comments

Comments
 (0)