diff --git a/src/DateTime.php b/src/DateTime.php index bf0f94a..c35d449 100644 --- a/src/DateTime.php +++ b/src/DateTime.php @@ -24,7 +24,7 @@ private function compile(string $date, string $format, string $timezone = 'null' PHP; } - private function evaluate(array $context, string $date, string $format, string $timezone = null) + private function evaluate(array $context, string $date, string $format, ?string $timezone = null) { return \DateTimeImmutable::createFromFormat($format, $date, null !== $timezone ? new \DateTimeZone($timezone) : null); } diff --git a/src/Now.php b/src/Now.php index a4d4b15..02951f3 100644 --- a/src/Now.php +++ b/src/Now.php @@ -17,14 +17,14 @@ public function __construct($name) ); } - private function compile(string $timezone = null): string + private function compile(?string $timezone = null): string { return <<compile(...)->bindTo($this), + $this->evaluate(...)->bindTo($this) + ); + } + + private function compile(string $pattern, string $subject): string + { + return <<