Skip to content

Commit

Permalink
Make types generation compatible with Carbon 3
Browse files Browse the repository at this point in the history
  • Loading branch information
kylekatarnls committed Mar 24, 2024
1 parent c4d5501 commit fe1b12f
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/Types/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Types;

use Carbon\Carbon;
use Carbon\FactoryImmutable;
use Cmixin\BusinessDay;
use ReflectionClass;
use ReflectionException;
Expand All @@ -26,11 +27,15 @@ protected function getMethods($boot)
BusinessDay::enable('\Carbon\Carbon');
});

$c = new ReflectionClass(Carbon::now());
$macros = $c->getProperty('globalMacros');
$macros->setAccessible(true);
try {
$c = new ReflectionClass(Carbon::now());
$macros = $c->getProperty('globalMacros');
$macros->setAccessible(true);

return $macros->getValue();
return $macros->getValue();
} catch (ReflectionException $exception) {
return FactoryImmutable::getInstance()->getSettings()['macros'] ?? [];
}
}

/**
Expand Down

0 comments on commit fe1b12f

Please sign in to comment.