Enhance PHPStan options and fix type-related issues#49
Open
fadrian06 wants to merge 11 commits into
Open
Conversation
…expected TOKEN_HORIZONTAL_WS at offset 145 on line 5
…d in iterable type array.
… type specified in iterable type array.
… ?? is not nullable.
…ed in iterable type array.
There was a problem hiding this comment.
Pull request overview
This PR improves static analysis/type safety for the authentication package by tightening PHPStan configuration and refining PHPDoc types in Auth and User to better reflect nullable DB state and user/error data structures.
Changes:
- Updated
phpstan.dist.neonto improve output formatting and reporting options, and to excludetestsfrom analysis. - Made
Auth::$dbexplicitly nullable and added a PHPStan assertion incheckDbConnection()to help inference after connection checks. - Refined
UserPHPDoc types for errors andupdate()input, and simplifiedgetAuthInfo()conditional checks.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/Auth/User.php | Tightens PHPDoc for user errors and update payloads; simplifies getAuthInfo() role/permission checks. |
| src/Auth.php | Makes DB property nullable, fixes PHPDoc return formatting, and adds PHPStan assertion for DB connection checks. |
| phpstan.dist.neon | Adjusts PHPStan reporting/options and excludes test paths from analysis. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What kind of change does this PR introduce? (pls check at least one)
Description
This pull request focuses on improving type safety and static analysis in the codebase, particularly for the authentication classes. The changes enhance PHPStan integration, clarify property and method types, and improve error reporting and documentation for user-related data.
Static analysis and type safety improvements:
phpstan.dist.neonto set a stricter error format, exclude test paths from analysis, and enable additional reporting options for unmatched or uncommented ignores.$dbproperty inAuth(src/Auth.php) to indicate it can be null, and initialized it as such.@phpstan-assert Db $this->db) to thecheckDbConnectionmethod inAuthto improve static analysis.User data and error handling enhancements:
User(src/Auth/User.php), specifying possible structures for error arrays. [1] [2]updatemethod inUserto specify the expected structure of the$userDataparameter, improving clarity for optional fields likeemail.@propertyannotation for$emailin theUserclass docblock for better documentation and IDE support.Minor corrections:
dbConnectionmethod ofAuthfor accuracy.getAuthInfoinUserby removing unnecessary null coalescing, as the properties are always initialized.Does this PR introduce a breaking change? (check one)