Problem/Motivation

On PHP 8.4, the following deprecation notices are triggered on every request that uses the module:

Deprecated: Drupal\rest_api_access_token\Model\Token::__construct(): Implicitly marking parameter $createdAt as nullable is deprecated, the explicit nullable type must be used instead in
/path/to/web/modules/contrib/rest_api_access_token/src/Model/Token.php on line 55

Deprecated: Drupal\rest_api_access_token\Model\Token::__construct(): Implicitly marking parameter $refreshedAt as nullable is deprecated, the explicit nullable type must be used instead in
/path/to/web/modules/contrib/rest_api_access_token/src/Model/Token.php on line 55

The root cause is in src/Model/Token.php, line 55, where both parameters use an implicit nullable type (a non-nullable type hint with a = NULL default), which PHP 8.4 deprecates in favour of an explicit ?Type notation:

// Current (triggers deprecation on PHP 8.4)
public function __construct(string $public, string $secret, int $userId, \DateTime $createdAt = NULL, \DateTime $refreshedAt = NULL)

Steps to reproduce

1. Install the module on Drupal 11 with PHP 8.4.
2. Make any authenticated request that triggers token creation/loading (e.g. call a REST endpoint secured by this module).
3. Check the PHP error log or enable display_errors.

Proposed resolution

Change the two affected parameters in src/Model/Token.php line 55 from implicit to explicit nullable.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

jjose.quevedo created an issue. See original summary.

jjose.quevedo’s picture

Status: Active » Needs review
jjose.quevedo’s picture

Status: Needs review » Reviewed & tested by the community