Skip to content

refactor: Resolve all phpstan errors (lvl 5) - #1404

Merged
paulbalandan merged 4 commits into
codeigniter4:developfrom
neznaika0:refactor/fix-phpstan-errors
Nov 13, 2026
Merged

paulbalandan merged 4 commits into
codeigniter4:developfrom
neznaika0:refactor/fix-phpstan-errors

Conversation

@neznaika0

Copy link
Copy Markdown
Contributor

Description

  • Enabled all PHPStan rules at level 5
  • cs-fixer allows $this for PHPUnit static methods; PHPStan now ignores them
  • @phpstan-* prefixes are irrelevant since the project relies entirely on PHPStan
  • Constructor property promotion changed: null has no meaning and properties should always have a value. Previously null was used for convenience of object initialization
  • NothingPersonalValidator::isNotPersonal() is now more precise
  • EmailConfig values have long been strings; (string) cast is no longer relevant
  • $credentials filtering: let us know if all empty values (0, '0', 0.0...) need to be checked
  • Updated code examples in docs/

If you approve these changes, I have more fixes for NothingPersonalValidator coming up.
Going forward, I can update the errors from the PHPStan baseline.

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

Comment thread src/Authentication/JWT/JWSEncoder.php Resolved
@neznaika0
neznaika0 force-pushed the refactor/fix-phpstan-errors branch from 1a1ac36 to 2db9061 Compare November 11, 2026 10:38

@neznaika0 neznaika0 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rebased.
But I left the properties without null; they should be present in all cases.

And console output:

 [WARNING] These rules are registered in both sets and "withRules()". Remove them from "withRules()" to avoid           
           duplications:                                                                                                
                                                                                                                        
           * Rector\PHPUnit\PHPUnit120\Rector\CallLike\CreateStubOverCreateMockArgRector *                              
           Rector\PHPUnit\PHPUnit120\Rector\ClassMethod\ExpressionCreateMockToCreateStubRector *                        
           Rector\PHPUnit\PHPUnit120\Rector\Class_\PropertyCreateMockToCreateStubRector *                               
           Rector\PHPUnit\PHPUnit120\Rector\Property\MockObjectVarToStubRector *                                        
           Rector\PHPUnit\CodeQuality\Rector\Class_\AddStubIntersectionVarToStubPropertyRector *                        
           Rector\PHPUnit\CodeQuality\Rector\ClassMethod\BareCreateMockAssignToDirectUseRector *                        
           Rector\PHPUnit\CodeQuality\Rector\MethodCall\RemoveExpectAnyFromMockRector *                                 
           Rector\PHPUnit\PHPUnit60\Rector\MethodCall\GetMockBuilderGetMockToCreateMockRector

Comment thread src/Authentication/JWT/JWSEncoder.php Resolved
Comment thread src/Authentication/JWTManager.php Resolved
@neznaika0

Copy link
Copy Markdown
Contributor Author

The analyzer didn’t complain about JWSDecoder class, but it was also modified in the previous PR. Do we need to update it here?

-   private JWSAdapterInterface $jwsAdapter;

    /**
     * @var string The key group. The array key of Config\AuthJWT::$keys.
     */
    protected $keyset = 'default';

-    public function __construct(?JWSAdapterInterface $jwsAdapter = null)
+    public function __construct(private ?JWSAdapterInterface $jwsAdapter = null)
    {

@michalsn

Copy link
Copy Markdown
Member

I guess we should.

Comment thread phpstan.dist.neon Resolved
@neznaika0
neznaika0 force-pushed the refactor/fix-phpstan-errors branch from 2db9061 to e94a95e Compare November 12, 2026 18:07
@neznaika0

Copy link
Copy Markdown
Contributor Author

Coveralls fixed in next PR

@paulbalandan
paulbalandan merged commit 69272ab into codeigniter4:develop Nov 13, 2026
35 of 37 checks passed
@datamweb datamweb added the refactor Pull requests that refactor code label Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor Pull requests that refactor code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants