Skip to content

chore: fix rector and phpstan errors#1355

Merged
datamweb merged 1 commit into
codeigniter4:developfrom
datamweb:fix-phpstan-errors
Jul 7, 2026
Merged

chore: fix rector and phpstan errors#1355
datamweb merged 1 commit into
codeigniter4:developfrom
datamweb:fix-phpstan-errors

Conversation

@datamweb

@datamweb datamweb commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

Description
See :
https://github.com/codeigniter4/shield/actions/runs/28875784066/job/85650363787?pr=1354
https://github.com/codeigniter4/shield/actions/runs/28875788566/job/85650379873?pr=1354

Note: Using configuration file /home/runner/work/shield/shield/phpstan.neon.dist.
   0/199 [░░░░░░░░░░░░░░░░░░░░░░░░░░░░]   0%
 199/199 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

Error: Ignored error "Parameter #1 $row (array|CodeIgniter\Shield\Entities\User) of method CodeIgniter\Shield\Models\UserModel::insert() should be contravariant with parameter $row (array<int|string, bool|float|int|object|string|null>|object|null) of method CodeIgniter\Model::insert()" (method.childParameterType) in path /home/runner/work/shield/shield/src/Models/UserModel.php was not matched in reported errors.
Error: Ignored error "Parameter #1 $row (array|CodeIgniter\Shield\Entities\User) of method CodeIgniter\Shield\Models\UserModel::save() should be contravariant with parameter $row (array<int|string, bool|float|int|object|string|null>|object) of method CodeIgniter\BaseModel::save()" (method.childParameterType) in path /home/runner/work/shield/shield/src/Models/UserModel.php was not matched in reported errors.
Error: Ignored error "Parameter #2 $row (array|CodeIgniter\Shield\Entities\User) of method CodeIgniter\Shield\Models\UserModel::update() should be contravariant with parameter $row (array<int|string, bool|float|int|object|string|null>|object|null) of method CodeIgniter\Model::update()" (method.childParameterType) in path /home/runner/work/shield/shield/src/Models/UserModel.php was not matched in reported errors.
Error: Parameter #1 $row (array|CodeIgniter\Shield\Entities\User) of method CodeIgniter\Shield\Models\UserModel::insert() should be contravariant with parameter $row (array<mixed>|object|null) of method CodeIgniter\Model::insert()
Error: Parameter #2 $row (array|CodeIgniter\Shield\Entities\User) of method CodeIgniter\Shield\Models\UserModel::update() should be contravariant with parameter $row (array<mixed>|object|null) of method CodeIgniter\Model::update()
Error: Parameter #1 $row (array|CodeIgniter\Shield\Entities\User) of method CodeIgniter\Shield\Models\UserModel::save() should be contravariant with parameter $row (array<mixed>|object) of method CodeIgniter\BaseModel::save()
 ------ ----------------------------------------------------------------------- 
  Line   src/Models/UserModel.php                                               
 ------ ----------------------------------------------------------------------- 
         Ignored error "Parameter #1 $row                                       
         (array|CodeIgniter\Shield\Entities\User) of method                     
         CodeIgniter\Shield\Models\UserModel::insert() should be contravariant  
         with parameter $row (array<int|string, bool|float|int|object|string|n  
         ull>|object|null) of method CodeIgniter\Model::insert()" (method.chil  
         dParameterType) in path                                                
         /home/runner/work/shield/shield/src/Models/UserModel.php was not       
         matched in reported errors.                                            
         🪪  ignore.unmatched (non-ignorable)                                   
         Ignored error "Parameter #1 $row                                       
         (array|CodeIgniter\Shield\Entities\User) of method                     
         CodeIgniter\Shield\Models\UserModel::save() should be contravariant    
         with parameter $row (array<int|string, bool|float|int|object|string|n  
         ull>|object) of method CodeIgniter\BaseModel::save()" (method.childPa  
         rameterType) in path                                                   
         /home/runner/work/shield/shield/src/Models/UserModel.php was not       
         matched in reported errors.                                            
         🪪  ignore.unmatched (non-ignorable)                                   
         Ignored error "Parameter #2 $row                                       
         (array|CodeIgniter\Shield\Entities\User) of method                     
         CodeIgniter\Shield\Models\UserModel::update() should be contravariant  
         with parameter $row (array<int|string, bool|float|int|object|string|n  
         ull>|object|null) of method CodeIgniter\Model::update()" (method.chil  
         dParameterType) in path                                                
         /home/runner/work/shield/shield/src/Models/UserModel.php was not       
         matched in reported errors.                                            
         🪪  ignore.unmatched (non-ignorable)                                   
  412    Parameter #1 $row (array|CodeIgniter\Shield\Entities\User) of method   
         CodeIgniter\Shield\Models\UserModel::insert() should be contravariant  
         with parameter $row (array<mixed>|object|null) of method CodeIgniter\  
         Model::insert()                                                        
         🪪  method.childParameterType                                          
  435    Parameter #2 $row (array|CodeIgniter\Shield\Entities\User) of method   
         CodeIgniter\Shield\Models\UserModel::update() should be contravariant  
         with parameter $row (array<mixed>|object|null) of method CodeIgniter\  
         Model::update()                                                        
         🪪  method.childParameterType                                          
  477    Parameter #1 $row (array|CodeIgniter\Shield\Entities\User) of method   
         CodeIgniter\Shield\Models\UserModel::save() should be contravariant    
         with parameter $row (array<mixed>|object) of method CodeIgniter\BaseM  
         odel::save()                                                           
         🪪  method.childParameterType                       
Run vendor/bin/rector process --dry-run --no-progress-bar

9 files with changes
====================

1) src/Authentication/Traits/HasAccessTokens.php:155

    ---------- begin diff ----------
@@ Line 155 @@

     /**
      * Sets the current active token for this user.
-     *
-     * @return $this
      */
     public function setAccessToken(?AccessToken $accessToken): self
     {
    ----------- end diff -----------

Applied rules:
 * RemoveDuplicatedReturnSelfDocblockRector


2) src/Authentication/Traits/HasHmacTokens.php:145

    ---------- begin diff ----------
@@ Line 145 @@

     /**
      * Sets the current active token for this user.
-     *
-     * @return $this
      */
     public function setHmacToken(?AccessToken $accessToken): self
     {
    ----------- end diff -----------

Applied rules:
 * RemoveDuplicatedReturnSelfDocblockRector


3) src/Authorization/Traits/Authorizable.php:26

    ---------- begin diff ----------
@@ Line 26 @@

     /**
      * Adds one or more groups to the current User.
-     *
-     * @return $this
      */
     public function addGroup(string ...$groups): self
     {
@@ Line 63 @@

     /**
      * Removes one or more groups from the user.
-     *
-     * @return $this
      */
     public function removeGroup(string ...$groups): self
     {
@@ Line 88 @@
      * so only those groups are valid for this user, removing
      * all groups not in this list.
      *
-     * @return $this
      *
      * @throws AuthorizationException
      */
@@ Line 150 @@
     /**
      * Adds one or more permissions to the current user.
      *
-     * @return $this
      *
      * @throws AuthorizationException
      */
@@ Line 188 @@

     /**
      * Removes one or more permissions from the current user.
-     *
-     * @return $this
      */
     public function removePermission(string ...$permissions): self
     {
@@ Line 213 @@
      * so only those permissions are valid for this user, removing
      * all permissions not in this list.
      *
-     * @return $this
      *
      * @throws AuthorizationException
      */
    ----------- end diff -----------

Applied rules:
 * RemoveDuplicatedReturnSelfDocblockRector


4) src/Auth.php:71

    ---------- begin diff ----------
@@ Line 71 @@

     /**
      * Sets the Authenticator alias that should be used for this request.
-     *
-     * @return $this
      */
     public function setAuthenticator(?string $alias = null): self
     {
    ----------- end diff -----------

Applied rules:
 * RemoveDuplicatedReturnSelfDocblockRector


5) src/Authentication/Authentication.php:69

    ---------- begin diff ----------
@@ Line 69 @@

     /**
      * Sets the User Provider to use.
-     *
-     * @return $this
      */
     public function setProvider(UserModel $provider): self
     {
    ----------- end diff -----------

Applied rules:
 * RemoveDuplicatedReturnSelfDocblockRector


6) src/Authentication/Authenticators/Session.php:112

    ---------- begin diff ----------
@@ Line 112 @@

     /**
      * Sets the $shouldRemember flag
-     *
-     * @return $this
      */
     public function remember(bool $shouldRemember = true): self
     {
    ----------- end diff -----------

Applied rules:
 * RemoveDuplicatedReturnSelfDocblockRector


7) src/Models/UserModel.php:76

    ---------- begin diff ----------
@@ Line 76 @@

     /**
      * Mark the next find* query to include identities
-     *
-     * @return $this
      */
     public function withIdentities(): self
     {
@@ Line 88 @@

     /**
      * Mark the next find* query to include groups
-     *
-     * @return $this
      */
     public function withGroups(): self
     {
@@ Line 100 @@

     /**
      * Mark the next find* query to include permissions
-     *
-     * @return $this
      */
     public function withPermissions(): self
     {
    ----------- end diff -----------

Applied rules:
 * RemoveDuplicatedReturnSelfDocblockRector


8) src/Test/AuthenticationTesting.php:27

    ---------- begin diff ----------
@@ Line 27 @@
      * Logs the user for testing purposes.
      *
      * @param bool $pending Whether pending login state or not.
-     *
-     * @return $this
      */
     public function actingAs(User $user, bool $pending = false): self
     {
    ----------- end diff -----------

Applied rules:
 * RemoveDuplicatedReturnSelfDocblockRector


9) src/Traits/Bannable.php:25

    ---------- begin diff ----------
@@ Line 25 @@

     /**
      * Ban the user from logging in.
-     *
-     * @return $this
      */
     public function ban(?string $message = null): self
     {
@@ Line 42 @@

     /**
      * Unban the user and allow them to login
-     *
-     * @return $this
      */
     public function unBan(): self
     {
    ----------- end diff -----------

Applied rules:
 * RemoveDuplicatedReturnSelfDocblockRector


 [OK] 9 files would have been changed (dry-run) by Rector   

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@datamweb datamweb force-pushed the fix-phpstan-errors branch from 90a7205 to 82db85d Compare July 7, 2026 19:55
@datamweb datamweb requested a review from paulbalandan July 7, 2026 19:55
@datamweb datamweb merged commit 5e69cdb into codeigniter4:develop Jul 7, 2026
37 checks passed
@datamweb datamweb deleted the fix-phpstan-errors branch July 7, 2026 20:03
@datamweb

datamweb commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator Author

@paulbalandan Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants