Skip to content

Commit 52a8e25

Browse files
[11.x] Chore: Decouple Str::random() from Validator (#56852)
* add support for flushing the global state of Illuminate\Validation\Validator * Update InteractsWithTestCaseLifecycle.php * Update Validator.php --------- Co-authored-by: Taylor Otwell <[email protected]>
1 parent 3ec3361 commit 52a8e25

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/Illuminate/Foundation/Testing/Concerns/InteractsWithTestCaseLifecycle.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
use Illuminate\Support\Once;
3434
use Illuminate\Support\Sleep;
3535
use Illuminate\Support\Str;
36+
use Illuminate\Validation\Validator;
3637
use Illuminate\View\Component;
3738
use Mockery;
3839
use Mockery\Exception\InvalidCountException;
@@ -187,6 +188,7 @@ protected function tearDownTheTestEnvironment(): void
187188
TrustProxies::flushState();
188189
TrustHosts::flushState();
189190
ValidateCsrfToken::flushState();
191+
Validator::flushState();
190192
WorkCommand::flushState();
191193

192194
if ($this->callbackException) {

src/Illuminate/Validation/Validator.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1657,6 +1657,16 @@ protected function callClassBasedExtension($callback, $parameters)
16571657
return $this->container->make($class)->{$method}(...array_values($parameters));
16581658
}
16591659

1660+
/**
1661+
* Flush the validator's global state.
1662+
*
1663+
* @return void
1664+
*/
1665+
public static function flushState()
1666+
{
1667+
static::$placeholderHash = null;
1668+
}
1669+
16601670
/**
16611671
* Handle dynamic calls to class methods.
16621672
*

0 commit comments

Comments
 (0)