Skip to content

Conversation

@huangdijia
Copy link
Member

Summary

Fixed PHPStan type assertions in database model type test files to ensure proper literal type recognition.

Changes

  • Updated return type assertions for findOr() and firstOr() methods in src/database/types/Model/Builder.php
    • Changed from User|int to 42|User format to properly represent literal types
  • Fixed string literal type assertion in src/database/types/Model/Collection.php
    • Changed from string|User to 'string'|User format for proper literal type recognition

Test plan

  • PHPStan analysis should pass with correct type assertions
  • Type inference should properly recognize literal types in test scenarios

These changes ensure PHPStan properly recognizes the literal types in the type analysis tests.

- Updated return type assertions for findOr() and firstOr() methods
  to use literal type format (42|User instead of User|int)
- Fixed string literal type assertion in Collection::find()
  to use single-quoted format ('string'|User instead of string|User)

These changes ensure PHPStan properly recognizes the literal types
in the type analysis tests.
@huangdijia huangdijia changed the base branch from master to 3.2 October 30, 2025 03:52
@limingxinleo limingxinleo merged commit cfdb564 into hyperf:3.2 Oct 30, 2025
76 checks passed
@huangdijia huangdijia deleted the fix/phpstan-type-assertions branch October 30, 2025 05:43
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