Aggiornato Composer

This commit is contained in:
Paolo A
2024-05-17 12:24:19 +00:00
parent 4ac62108b5
commit ec201d75b2
2238 changed files with 38684 additions and 59785 deletions

View File

@@ -28,7 +28,7 @@ trait Test
/**
* A test Carbon instance to be returned when now instances are created.
*
* @var static
* @var Closure|static|null
*/
protected static $testNow;
@@ -59,15 +59,13 @@ trait Test
*
* /!\ Use this method for unit tests only.
*
* @param Closure|static|string|false|null $testNow real or mock Carbon instance
* @param DateTimeInterface|Closure|static|string|false|null $testNow real or mock Carbon instance
*/
public static function setTestNow($testNow = null)
{
if ($testNow === false) {
$testNow = null;
}
static::$testNow = \is_string($testNow) ? static::parse($testNow) : $testNow;
static::$testNow = $testNow instanceof self || $testNow instanceof Closure
? $testNow
: static::make($testNow);
}
/**
@@ -87,7 +85,7 @@ trait Test
*
* /!\ Use this method for unit tests only.
*
* @param Closure|static|string|false|null $testNow real or mock Carbon instance
* @param DateTimeInterface|Closure|static|string|false|null $testNow real or mock Carbon instance
*/
public static function setTestNowAndTimezone($testNow = null, $tz = null)
{
@@ -121,16 +119,22 @@ trait Test
*
* /!\ Use this method for unit tests only.
*
* @param Closure|static|string|false|null $testNow real or mock Carbon instance
* @param Closure|null $callback
* @template T
*
* @return mixed
* @param DateTimeInterface|Closure|static|string|false|null $testNow real or mock Carbon instance
* @param Closure(): T $callback
*
* @return T
*/
public static function withTestNow($testNow = null, $callback = null)
public static function withTestNow($testNow, $callback)
{
static::setTestNow($testNow);
$result = $callback();
static::setTestNow();
try {
$result = $callback();
} finally {
static::setTestNow();
}
return $result;
}