Implicit nullable parameters are deprecated in PHP 8.4
-
Since PHP 8.4, implicit nullable parameter types are deprecated. Running WP OAuth Server on PHP 8.4 causes a slew of deprecation warnings such as:
[08-Apr-2026 13:57:32 UTC] PHP Deprecated: WPOAuth2\Server::grantAccessToken(): Implicitly marking parameter $response as nullable is deprecated, the explicit nullable type must be used instead in .../plugins/oauth2-provider/library/WPOAuth2/Server.php on line 261See: https://wiki.php.net/rfc/deprecate-implicitly-nullable-types
Function definitions should be altered to add the explicit nullable types using the
?character, like so:public function grantAccessToken( RequestInterface $request, ResponseInterface $response = null ) {
# Should be changed to:
public function grantAccessToken( RequestInterface $request, ?ResponseInterface $response = null ) {The PHP linter does not appear to find occurrences of this, but (thanks to the consistent formatting of this plugin’s code) the following command will reveal many of them:
grep -RIPs 'function.*[^,(] \$[a-zA-Z0-9]+ = *null' ../plugins/oauth2-provider/
You must be logged in to reply to this topic.