Skip to content

Fix PHPDoc generics for query results and model collections - #59

Merged
matthi4s merged 1 commit into
masterfrom
fix-query-result-generics
Oct 29, 2026
Merged

matthi4s merged 1 commit into
masterfrom
fix-query-result-generics

Conversation

@matthi4s

Copy link
Copy Markdown
Member

Docblock-only change, no runtime changes.

  • GenericModel::query(), select(), update() and set(): change @return QueryResult<static>|static[] to @return QueryResult<static>. The |static[] part contradicts the native QueryResult return type, so PHPStan discarded the whole docblock and resolved results to plain QueryResult with ModelInterface elements.
  • ModelCollection: add @implements Iterator<int, TModel> and @implements ArrayAccess<int, TModel> so foreach and $result[0] resolve to TModel.

Verified with PHPStan dumpType: TestModel::select() now gives QueryResult<TestModel> (before: QueryResult), and iterating it or reading $result[0] gives TestModel (before: ModelInterface). PHPUnit passes.

@matthi4s
matthi4s merged commit 3f61888 into master Oct 29, 2026
3 checks passed
@matthi4s
matthi4s deleted the fix-query-result-generics branch October 29, 2026 13:52
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.

1 participant