Skip to content

Commit

Permalink
Allow both Carbon 2 and 3
Browse files Browse the repository at this point in the history
  • Loading branch information
kylekatarnls committed Jan 26, 2024
1 parent a1bfcaf commit ee58c7d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"league/commonmark": "^2.2.1",
"league/flysystem": "^3.8.0",
"monolog/monolog": "^3.0",
"nesbot/carbon": "^3.0.0-beta.3@beta",
"nesbot/carbon": "^2.72.2 || ^3.0.0-beta.3@beta",
"nunomaduro/termwind": "^2.0",
"psr/container": "^1.1.1|^2.0.1",
"psr/log": "^1.0|^2.0|^3.0",
Expand Down
15 changes: 11 additions & 4 deletions src/Illuminate/Support/Carbon.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Illuminate\Support;

use Carbon\Carbon as BaseCarbon;
use Carbon\CarbonImmutable as BaseCarbonImmutable;
use Illuminate\Support\Traits\Conditionable;
use Illuminate\Support\Traits\Dumpable;
use Ramsey\Uuid\Uuid;
Expand All @@ -12,13 +13,19 @@ class Carbon extends BaseCarbon
{
use Conditionable, Dumpable;

/**
* {@inheritdoc}
*/
public static function setTestNow(mixed $testNow = null): void
{
BaseCarbon::setTestNow($testNow);
BaseCarbonImmutable::setTestNow($testNow);
}

/**
* Create a Carbon instance from a given ordered UUID or ULID.
*
* @param \Ramsey\Uuid\Uuid|\Symfony\Component\Uid\Ulid|string $id
* @return \Illuminate\Support\Carbon
*/
public static function createFromId($id)
public static function createFromId(Uuid|Ulid|string $id): static
{
if (is_string($id)) {
$id = Ulid::isValid($id) ? Ulid::fromString($id) : Uuid::fromString($id);
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Support/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"illuminate/conditionable": "^11.0",
"illuminate/contracts": "^11.0",
"illuminate/macroable": "^11.0",
"nesbot/carbon": "^3.0.0-beta.3@beta",
"nesbot/carbon": "^2.72.2 || ^3.0.0-beta.3@beta",
"voku/portable-ascii": "^2.0"
},
"conflict": {
Expand Down

0 comments on commit ee58c7d

Please sign in to comment.