diff --git a/src/DateTimeInterface.php b/src/DateTimeInterface.php index d6ba0dc..8b872a8 100644 --- a/src/DateTimeInterface.php +++ b/src/DateTimeInterface.php @@ -105,10 +105,10 @@ public function format_i18n( $format = null ); * @link https://www.php.net/manual/en/datetime.createfromformat.php * @link https://www.php.net/manual/en/datetimeimmutable.createfromformat.php * - * @param string $format Format accepted by date(). - * @param string $time String representing the time. - * @param \DateTimeZone $timezone A DateTimeZone object representing the desired time zone. + * @param string $format Format accepted by date(). + * @param string $time String representing the time. + * @param \DateTimeZone|null $timezone A DateTimeZone object representing the desired time zone. * @return self|false */ - public static function create_from_format( $format, $time, \DateTimeZone $timezone = null ); + public static function create_from_format( $format, $time, ?\DateTimeZone $timezone = null ); } diff --git a/src/DateTimeTrait.php b/src/DateTimeTrait.php index 734fc65..c891a94 100644 --- a/src/DateTimeTrait.php +++ b/src/DateTimeTrait.php @@ -273,14 +273,14 @@ public static function createFromFormat( // phpcs:ignore WordPress.NamingConvent * * @since 1.0.1 * - * @param string $format Format accepted by date(). - * @param string $time String representing the time. - * @param \DateTimeZone $timezone A DateTimeZone object representing the desired time zone. + * @param string $format Format accepted by date(). + * @param string $time String representing the time. + * @param \DateTimeZone|null $timezone A DateTimeZone object representing the desired time zone. * * @return self|false */ #[\ReturnTypeWillChange] - public static function create_from_format( $format, $time, \DateTimeZone $timezone = null ) { + public static function create_from_format( $format, $time, ?\DateTimeZone $timezone = null ) { /* * In PHP 5.6 or lower it's not possible to pass in an empty (null) timezone object. * This will result in a `DateTime::createFromFormat() expects parameter 3 to be DateTimeZone, null given` error.