diff --git a/src/Illuminate/Foundation/Testing/Concerns/InteractsWithTestCaseLifecycle.php b/src/Illuminate/Foundation/Testing/Concerns/InteractsWithTestCaseLifecycle.php index 0daabf1ce139..c7de47afa797 100644 --- a/src/Illuminate/Foundation/Testing/Concerns/InteractsWithTestCaseLifecycle.php +++ b/src/Illuminate/Foundation/Testing/Concerns/InteractsWithTestCaseLifecycle.php @@ -184,6 +184,7 @@ protected function tearDownTheTestEnvironment(): void Queue::createPayloadUsing(null); RegisterProviders::flushState(); Sleep::fake(false); + Str::resetFactoryState(); TrimStrings::flushState(); TrustProxies::flushState(); TrustHosts::flushState(); diff --git a/src/Illuminate/Support/Str.php b/src/Illuminate/Support/Str.php index 30dfb411107f..4583ed4f5c80 100644 --- a/src/Illuminate/Support/Str.php +++ b/src/Illuminate/Support/Str.php @@ -1112,7 +1112,7 @@ public static function random($length = 16) /** * Set the callable that will be used to generate random strings. * - * @param callable|null $factory + * @param (callable(int): string)|null $factory * @return void */ public static function createRandomStringsUsing(?callable $factory = null) @@ -1913,7 +1913,7 @@ public static function orderedUuid() /** * Set the callable that will be used to generate UUIDs. * - * @param callable|null $factory + * @param (callable(): \Ramsey\Uuid\UuidInterface)|null $factory * @return void */ public static function createUuidsUsing(?callable $factory = null) @@ -1925,7 +1925,7 @@ public static function createUuidsUsing(?callable $factory = null) * Set the sequence that will be used to generate UUIDs. * * @param array $sequence - * @param callable|null $whenMissing + * @param (callable(): \Ramsey\Uuid\UuidInterface)|null $whenMissing * @return void */ public static function createUuidsUsingSequence(array $sequence, $whenMissing = null) @@ -2020,7 +2020,7 @@ public static function createUlidsNormally() /** * Set the callable that will be used to generate ULIDs. * - * @param callable|null $factory + * @param (callable(): \Symfony\Component\Uid\Ulid)|null $factory * @return void */ public static function createUlidsUsing(?callable $factory = null) @@ -2032,7 +2032,7 @@ public static function createUlidsUsing(?callable $factory = null) * Set the sequence that will be used to generate ULIDs. * * @param array $sequence - * @param callable|null $whenMissing + * @param (callable(): \Symfony\Component\Uid\Ulid)|null $whenMissing * @return void */ public static function createUlidsUsingSequence(array $sequence, $whenMissing = null) @@ -2096,4 +2096,16 @@ public static function flushCache() static::$camelCache = []; static::$studlyCache = []; } + + /** + * Return all factory functions to their default state. + * + * @return void + */ + public static function resetFactoryState() + { + static::createRandomStringsNormally(); + static::createUlidsNormally(); + static::createUuidsNormally(); + } }