File tree 2 files changed +10
-0
lines changed
2 files changed +10
-0
lines changed Original file line number Diff line number Diff line change 21
21
use function in_array ;
22
22
use function is_array ;
23
23
use function sprintf ;
24
+ use function trigger_error ;
25
+ use const E_USER_DEPRECATED ;
24
26
25
27
/**
26
28
* Basic structure of the JWT
@@ -303,6 +305,10 @@ public function isExpired(DateTimeInterface $now = null)
303
305
return false ;
304
306
}
305
307
308
+ if ($ now === null ) {
309
+ trigger_error ('Not providing the current time is deprecated. Please pass an instance of DateTimeInterface. ' , E_USER_DEPRECATED );
310
+ }
311
+
306
312
$ now = $ now ?: new DateTimeImmutable ();
307
313
308
314
return $ now > $ this ->claims ->get (RegisteredClaims::EXPIRATION_TIME );
Original file line number Diff line number Diff line change 27
27
*/
28
28
class TokenTest extends \PHPUnit \Framework \TestCase
29
29
{
30
+ use CheckForDeprecations;
31
+
30
32
/**
31
33
* @test
32
34
*
@@ -920,6 +922,8 @@ public function isExpiredShouldReturnFalseWhenTokenDoesNotExpires()
920
922
*/
921
923
public function isExpiredShouldReturnFalseWhenTokenIsNotExpired ()
922
924
{
925
+ $ this ->expectDeprecation ('Not providing the current time is deprecated. Please pass an instance of DateTimeInterface. ' );
926
+
923
927
$ token = new Token (
924
928
['alg ' => 'none ' ],
925
929
['exp ' => new DateTimeImmutable ('+500 seconds ' )]
You can’t perform that action at this time.
0 commit comments