Skip to content

Commit

Permalink
Use #[\ReturnTypeWillChange] attribute in favor of union return typ…
Browse files Browse the repository at this point in the history
…e for backwards compatibility.
  • Loading branch information
rvdsteege committed Dec 28, 2022
1 parent deac793 commit 7842a7f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/DateTimeTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,9 @@ public function format_i18n( $format = null ) {
*
* @return self|false
*/
#[\ReturnTypeWillChange]
// phpcs:ignore WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid
public static function createFromFormat( $format, $time, $timezone = null ): self|false {
public static function createFromFormat( $format, $time, $timezone = null ) {
return self::create_from_format( $format, $time, $timezone );
}

Expand All @@ -272,7 +273,8 @@ public static function createFromFormat( $format, $time, $timezone = null ): sel
*
* @return self|false
*/
public static function create_from_format( $format, $time, \DateTimeZone $timezone = null ): self|false {
#[\ReturnTypeWillChange]
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.
Expand Down

0 comments on commit 7842a7f

Please sign in to comment.