Skip to content

Commit

Permalink
hand-remove almost all the remaining __NonRx
Browse files Browse the repository at this point in the history
Summary: onthetin

Reviewed By: dneiter

Differential Revision: D26712608

fbshipit-source-id: aea342ba5ee17917ed9db4db783399d68dd32b74
  • Loading branch information
DavidSnider authored and facebook-github-bot committed Feb 28, 2021
1 parent 8d47005 commit 6e04229
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 16 deletions.
3 changes: 1 addition & 2 deletions src/dict/order.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,9 @@ function reverse<Tk as arraykey, Tv>(
* Time complexity: O(n)
* Space complexity: O(n)
*/
<<__NonRx('Randomness')>>
function shuffle<Tk as arraykey, Tv>(
KeyedTraversable<Tk, Tv> $container,
): dict<Tk, Tv> {
)[defaults]: dict<Tk, Tv> {
$dict = cast_clear_legacy_array_mark($container);
return Vec\keys($container)
|> Vec\shuffle($$)
Expand Down
9 changes: 3 additions & 6 deletions src/random/pseudo.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
*
* For secure random floats, see `SecureRandom\float`.
*/
<<__NonRx('Randomness')>>
function float(): float {
function float()[defaults]: float {
return (float)(namespace\int(0, Math\INT53_MAX - 1) / Math\INT53_MAX);
}

Expand All @@ -29,11 +28,10 @@ function float(): float {
*
* For secure random integers, see `SecureRandom\int`.
*/
<<__NonRx('Randomness')>>
function int(
int $min = \PHP_INT_MIN,
int $max = \PHP_INT_MAX,
): int {
)[defaults]: int {
invariant(
$min <= $max,
'Expected $min (%d) to be less than or equal to $max (%d).',
Expand All @@ -50,11 +48,10 @@ function int(
*
* For secure random strings, see `SecureRandom\string`.
*/
<<__NonRx('Randomness')>>
function string(
int $length,
?string $alphabet = null,
): string {
)[defaults]: string {
// This is a temporary alias. You should never, ever depend on this function
// being cryptographically secure.
return SecureRandom\string($length, $alphabet);
Expand Down
9 changes: 3 additions & 6 deletions src/random/secure.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
*
* For pseudorandom floats, see `PseudoRandom\float`.
*/
<<__NonRx('Randomness')>>
function float(): float {
function float()[defaults]: float {
return (float)(namespace\int(0, Math\INT53_MAX - 1) / Math\INT53_MAX);
}

Expand All @@ -29,11 +28,10 @@ function float(): float {
*
* For pseudorandom integers, see `PseudoRandom\int`.
*/
<<__NonRx('Randomness')>>
function int(
int $min = \PHP_INT_MIN,
int $max = \PHP_INT_MAX,
): int {
)[defaults]: int {
invariant(
$min <= $max,
'Expected $min (%d) to be less than or equal to $max (%d).',
Expand All @@ -49,11 +47,10 @@ function int(
*
* For pseudorandom strings, see `PseudoRandom\string`.
*/
<<__NonRx('Randomness')>>
function string(
int $length,
?string $alphabet = null,
): string {
)[defaults]: string {
return _Private\random_string(
/* HH_FIXME[2049] calling stdlib directly */
/* HH_FIXME[4107] calling stdlib directly */
Expand Down
3 changes: 1 addition & 2 deletions src/vec/order.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,9 @@ function reverse<Tv>(
* Time complexity: O(n)
* Space complexity: O(n)
*/
<<__NonRx('Randomness')>>
function shuffle<Tv>(
Traversable<Tv> $traversable,
): vec<Tv> {
)[defaults]: vec<Tv> {
$vec = cast_clear_legacy_array_mark($traversable);
/* HH_FIXME[2049] calling stdlib directly */
/* HH_FIXME[4107] calling stdlib directly */
Expand Down

0 comments on commit 6e04229

Please sign in to comment.