-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Open
Description
Description:
In PHP 8.2 and later, passing a nullable parameter without explicitly marking it as ?callable
is deprecated. The Tymon\JWTAuth\Claims\Collection::getByClaimName()
method currently defines $callback
as callable $callback = null
, which triggers a deprecation warning.
Error Message:
PHP Deprecated: Tymon\JWTAuth\Claims\Collection::getByClaimName(): Implicitly marking parameter $callback as nullable is deprecated, the explicit nullable type must be used instead in /app/vendor/tymon/jwt-auth/src/Claims/Collection.php on line 38
Affected Code:
/**
* Get a Claim instance by its unique name.
*
* @param string $name
* @param callable $callback
* @param mixed $default
* @return \Tymon\JWTAuth\Claims\Claim
*/
public function getByClaimName($name, callable $callback = null, $default = null)
{
return $this->filter(function (Claim $claim) use ($name) {
return $claim->getName() === $name;
})->first($callback, $default);
}
Suggested Fix:
Modify the function signature to explicitly mark $callback
as nullable:
public function getByClaimName($name, ?callable $callback = null, $default = null)
Steps to Reproduce:
- Use PHP 8.2 or later.
- Install
tymon/jwt-auth
and attempt to callgetByClaimName()
. - Observe the deprecation warning in the logs.
Environment Details:
- PHP Version: ^8.2
- Laravel Version: ^11.0
- jwt-auth Version: ^2.1
Impact:
This deprecation warning will become a fatal error in future PHP versions, making it necessary to update the function signature.
Would appreciate a fix for this issue! Thanks for maintaining this library. 🚀
Metadata
Metadata
Assignees
Labels
No labels