Repository navigation
Return static from the chainable methods - #20
Merged
Merged
Conversation
The previous change gave __call a `static` return type, but the real
chainable methods (skipValidation, useOr, union, unionAll) still
declared `self`. A chain that passes through one of them drops back to
QueryGenerator, so a subclass's own methods after it, like
`(new SubQuery)->...->skipValidation()->getAll()`, resolve to __call and
type as QueryGenerator instead of the subclass's result.
build() always returns `[$query, $params]`, a two-element list.
Declaring it as `list{string, list<mixed>}` instead of
`array{0: string, 1: list<mixed>}` lets callers that declare
`array{string, array}` accept it. The params stay `list<mixed>`: they
are whatever values callers pass in.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jarstelfox
marked this pull request as ready for review
November 24, 2026 00:05
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.
🤖
Follow-up to #19. That PR typed
__callas returningstatic, but the chainable methods that are real methods still sayself. So a chain through one of them drops back to plainQueryGenerator. In(new SubQuery)->join(...)->skipValidation()->getAll(), Psalm resolvesgetAllthrough__calland thinks the rows are aQueryGenerator. Tracked in iFixit/ifixit#66899.Changes
skipValidation(),useOr(),union(),unionAll()(and the privateaddUnion()) now returnstatic. Each already returns$this.build(): documented aslist{string, list<mixed>}instead ofarray{0: string, 1: list<mixed>}. It returns[$query, $params], so a list is accurate, and callers that declarearray{string, array}now accept it. The params keeplist<mixed>because they are whatever values callers pass in.Checks
Run locally on PHP 8.3, the version CI uses:
vendor/bin/phpunit QueryGeneratorTest.php: 17 tests, 111 assertions, OKvendor/bin/psalm --no-cache: no errors, no baseline change🤖 Generated with Claude Code