feature: Added PHPStan type analysis for hyperf/collection
#7578
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.
Summary
Fixed all 14 PHPStan type analysis errors and reorganized type test files into a more logical directory structure.
Changes
Type Test File Reorganization
src/database/tests/types/tosrc/collection/types/src/database/tests/types/tosrc/database/types/phpstan.types.neon.distconfiguration to reflect new pathsPHPStan Type Fixes
Collection Types (src/collection/types/)
Collection.php (3 errors fixed):
mapToDictionaryreturn type:array<int, float>→array<int, float|int>mapToGroupsreturn type:Collection<int, float>→Collection<int, float|int>zipreturn type:Collection<int, float|int>→Collection<int, array{float}|int>Functions.php (1 error fixed):
non-falsy-stringinstead of genericstringLazyCollection.php (4 errors fixed):
lowercase-string&numeric-string&uppercase-stringtypeDatabase Types (src/database/types/)
Model/Builder.php (4 errors fixed):
findOrandfirstOrunion type ordering:User|int→42|User(literal type)Model/Collection.php (1 error fixed):
string|User→'string'|User(literal string type)Model/Relations.php (1 error fixed):
Relation::noConstraintsreturn type to match PHPStan's precise inferenceTesting
All PHPStan type checks now pass:
composer analyse-types # ✅ [OK] No errorsRelated Issues
Fixes type analysis errors that were preventing proper type checking in the codebase.