File tree Expand file tree Collapse file tree 2 files changed +14
-4
lines changed
Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change 3232
3333namespace Platine \OAuth2 \Entity ;
3434
35+ use DateMalformedStringException ;
3536use DateTime ;
3637use DateTimeInterface ;
3738
@@ -233,9 +234,18 @@ protected static function createNew(
233234
234235 $ expireAt = null ;
235236 if ($ ttl > 0 ) {
236- $ res = (new DateTime ())->modify (sprintf ('%+d seconds ' , $ ttl ));
237- if ($ res !== false ) {
238- $ expireAt = $ res ;
237+ // Since PHP >= 8.3 DateTime::modify() now throws
238+ // DateMalformedStringException if an invalid string is passed.
239+ if (PHP_VERSION_ID >= 80300 ) {
240+ try {
241+ $ expireAt = (new DateTime ())->modify (sprintf ('%+d seconds ' , $ ttl ));
242+ } catch (DateMalformedStringException $ ex ) {
243+ }
244+ } else {
245+ $ res = (new DateTime ())->modify (sprintf ('%+d seconds ' , $ ttl ));
246+ if ($ res !== false ) {
247+ $ expireAt = $ res ;
248+ }
239249 }
240250 }
241251
Original file line number Diff line number Diff line change @@ -87,7 +87,7 @@ final public function __construct()
8787 */
8888 public static function createNewClient (
8989 string $ name ,
90- string |array $ redirectUris = null ,
90+ string |array | null $ redirectUris = null ,
9191 ?array $ scopes = null
9292 ): self {
9393 if (is_string ($ redirectUris )) {
You can’t perform that action at this time.
0 commit comments