Skip to content

Commit

Permalink
Merge pull request #2769 from takaram/withTestNow_signature
Browse files Browse the repository at this point in the history
Improve withTestNow() signature
  • Loading branch information
kylekatarnls authored Feb 22, 2023
2 parents 610db40 + 257e5cf commit 020e560
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
7 changes: 5 additions & 2 deletions src/Carbon/CarbonInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -5120,12 +5120,15 @@ public function weeksInYear($dayOfWeek = null, $dayOfYear = null);
*
* /!\ Use this method for unit tests only.
*
* @template T
*
* @param DateTimeInterface|Closure|static|string|false|null $testNow real or mock Carbon instance
* @param Closure|null $callback
* @param Closure(): T $callback
*
* @return mixed
* @phpstan-return T
*/
public static function withTestNow($testNow = null, $callback = null);
public static function withTestNow($testNow, $callback);

/**
* Create a Carbon instance for yesterday.
Expand Down
2 changes: 1 addition & 1 deletion src/Carbon/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@
* You should rather use the ->settings() method.
* Or you can use method variants: addYearsWithOverflow/addYearsNoOverflow, same variants
* are available for quarters, years, decade, centuries, millennia (singular and plural forms).
* @method mixed withTestNow($testNow = null, $callback = null) Temporarily sets a static date to be used within the callback.
* @method mixed withTestNow($testNow, $callback) Temporarily sets a static date to be used within the callback.
* Using setTestNow to set the date, executing the callback, then
* clearing the test instance.
* /!\ Use this method for unit tests only.
Expand Down
2 changes: 1 addition & 1 deletion src/Carbon/FactoryImmutable.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@
* You should rather use the ->settings() method.
* Or you can use method variants: addYearsWithOverflow/addYearsNoOverflow, same variants
* are available for quarters, years, decade, centuries, millennia (singular and plural forms).
* @method mixed withTestNow($testNow = null, $callback = null) Temporarily sets a static date to be used within the callback.
* @method mixed withTestNow($testNow, $callback) Temporarily sets a static date to be used within the callback.
* Using setTestNow to set the date, executing the callback, then
* clearing the test instance.
* /!\ Use this method for unit tests only.
Expand Down
7 changes: 5 additions & 2 deletions src/Carbon/Traits/Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,15 @@ public static function setTestNowAndTimezone($testNow = null, $tz = null)
*
* /!\ Use this method for unit tests only.
*
* @template T
*
* @param DateTimeInterface|Closure|static|string|false|null $testNow real or mock Carbon instance
* @param Closure|null $callback
* @param Closure(): T $callback
*
* @return mixed
* @phpstan-return T
*/
public static function withTestNow($testNow = null, $callback = null)
public static function withTestNow($testNow, $callback)
{
static::setTestNow($testNow);

Expand Down

0 comments on commit 020e560

Please sign in to comment.