Skip to content

add '?' to nullable method parameters#229

Merged
kelvinmo merged 4 commits intokelvinmo:masterfrom
shu-yusa:master
Aug 1, 2025
Merged

add '?' to nullable method parameters#229
kelvinmo merged 4 commits intokelvinmo:masterfrom
shu-yusa:master

Conversation

@shu-yusa
Copy link
Copy Markdown
Contributor

Issue: #228

From PHP8.4, a parameter that has null as a default value has to be typed as a nullable type: https://www.php.net/manual/en/migration84.deprecated.php
This PR adds ? to the method parameters that take null as a default value.

@shu-yusa
Copy link
Copy Markdown
Contributor Author

cc: @kelvinmo

@kelvinmo kelvinmo linked an issue Jul 30, 2025 that may be closed by this pull request
@shu-yusa
Copy link
Copy Markdown
Contributor Author

I just noticed the CI has the matrix for different PHP versions. Let me add 8.4 to the matrix.

@kelvinmo
Copy link
Copy Markdown
Owner

Please update line 54 of .github/workflows/ci.yml to also use version 8.4. You will find that there are a few more method signatures that need to be updated.

 ------ ---------------------------------------------------------------------------------------------------------- 
  Line   SimpleJWT/InvalidTokenException.php                                                                       
 ------ ---------------------------------------------------------------------------------------------------------- 
  :90    Deprecated in PHP 8.4: Parameter #3 $previous (Exception) is implicitly nullable via default value null.  
         🪪  parameter.implicitlyNullable                                                                          
 ------ ---------------------------------------------------------------------------------------------------------- 

 ------ -------------------------------------------------------------------------------------------------- 
  Line   SimpleJWT/JWT.php                                                                                 
 ------ -------------------------------------------------------------------------------------------------- 
  :99    Deprecated in PHP 8.4: Parameter #4 $kid (string) is implicitly nullable via default value null.  
         🪪  parameter.implicitlyNullable                                                                  
  :207   Deprecated in PHP 8.4: Parameter #4 $alg (string) is implicitly nullable via default value null.  
         🪪  parameter.implicitlyNullable                                                                  
 ------ -------------------------------------------------------------------------------------------------- 

 ------ ------------------------------------------------------------------------------------------------------- 
  Line   SimpleJWT/Keys/Key.php                                                                                 
 ------ ------------------------------------------------------------------------------------------------------- 
  :237   Deprecated in PHP 8.4: Parameter #1 $password (string) is implicitly nullable via default value null.  
         🪪  parameter.implicitlyNullable                                                                       
 ------ ------------------------------------------------------------------------------------------------------- 

 ------ ----------------------------------------------------------------------------------------------------- 
  Line   SimpleJWT/Keys/KeyFactory.php                                                                        
 ------ ----------------------------------------------------------------------------------------------------- 
  :106   Deprecated in PHP 8.4: Parameter #2 $format (string) is implicitly nullable via default value null.  
         🪪  parameter.implicitlyNullable                                                                     
 ------ ----------------------------------------------------------------------------------------------------- 

 ------ ------------------------------------------------------------------------------------------------------- 
  Line   SimpleJWT/Keys/KeySet.php                                                                              
 ------ ------------------------------------------------------------------------------------------------------- 
  :95    Deprecated in PHP 8.4: Parameter #1 $password (string) is implicitly nullable via default value null.  
         🪪  parameter.implicitlyNullable                                                                       
 ------ ------------------------------------------------------------------------------------------------------- 

 ------ ----------------------------------------------------------------------------------------------- 
  Line   SimpleJWT/Util/CBOR/DataItem.php                                                               
 ------ ----------------------------------------------------------------------------------------------- 
  :127   Deprecated in PHP 8.4: Parameter #3 $tag (int) is implicitly nullable via default value null.  
         🪪  parameter.implicitlyNullable                                                               
 ------ ----------------------------------------------------------------------------------------------- 

@shu-yusa
Copy link
Copy Markdown
Contributor Author

thank you for the feedback! I fixed them

@kelvinmo kelvinmo merged commit 85e43e6 into kelvinmo:master Aug 1, 2025
6 checks passed
@kelvinmo
Copy link
Copy Markdown
Owner

kelvinmo commented Aug 1, 2025

💚 All backports created successfully

Status Branch Result
1.0

Questions ?

Please refer to the Backport tool documentation and see the Github Action logs for details

kelvinmo added a commit that referenced this pull request Aug 2, 2025
[1.0] Add '?' to nullable method parameters (#229)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Nullable method parameters require "?" in PHP 8.4

2 participants