Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat(SelectQuery): refine Psalm integer types on query bounds#257

Merged
roxblnfk merged 1 commit into
2.x from
bugfix/runchunks-reject-non-positive-limit
Jun 11, 2026
Merged

feat(SelectQuery): refine Psalm integer types on query bounds #257
roxblnfk merged 1 commit into
2.x from
bugfix/runchunks-reject-non-positive-limit

Conversation

@roxblnfk

@roxblnfk roxblnfk commented Jun 11, 2026
edited
Loading

Copy link
Copy Markdown
Member

🔍 What was changed

Refined the Psalm types in SelectQuery so numeric bounds and string constraints are expressed at the type level.

Added integer bounds:

Method Annotation Meaning
runChunks() @param int<1, max> $limit Chunk size must be positive — a non-positive value never advances the offset and would spin in an endless loop.
getLimit() @return int<0, max>|null Limit is >= 0 or null (0 disables limiting).
getOffset() @return int<0, max>|null Offset is >= 0 or null.
count() @return int<0, max> A row count is never negative.

Simplified existing hints: dropped the redundant psalm- prefix from the non-empty-string column/method hints on count(), avg(), max(), min(), sum() and runAggregate() — plain @param advanced types are now broadly supported (Psalm, PHPStan, PhpStorm).

Note

Annotation-only — runtime behaviour and public signatures are unchanged.

🤔 Why?

Expressing these bounds as Psalm types lets static analysis catch invalid values at the call site instead of failing (or hanging) at runtime, and gives consumers more precise return types. The endless-loop risk on a non-positive chunk size was surfaced by the Copilot review on #255.

Setter params (limit() / offset()) are intentionally left as-is: narrowing them would break the Spiral\Pagination\PaginableInterface contract (MoreSpecificImplementedParamType). The return-type refinements are safe because LessSpecificReturnStatement / MoreSpecificReturnType are already suppressed project-wide in psalm.xml.

📝 Checklist

  • How was this tested:

    • Tested manually
    • Unit tests added

    Verified with psalm (no new issues introduced) and php-cs-fixer (clean). No unit tests are added — these are static-analysis annotations with no runtime effect.

📃 Documentation

Not needed — type-level annotations, public API signatures unchanged.

codecov Bot commented Jun 11, 2026
edited
Loading

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.68%. Comparing base (38c3403) to head (39d0018).

Additional details and impacted files
@@ Coverage Diff @@
## 2.x #257 +/- ##
=========================================
 Coverage 95.68% 95.68% 
 Complexity 2038 2038 
=========================================
 Files 137 137 
 Lines 5775 5775 
=========================================
 Hits 5526 5526 
 Misses 249 249 

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@roxblnfk roxblnfk force-pushed the bugfix/runchunks-reject-non-positive-limit branch from 7c66df1 to b2d4cad Compare June 11, 2026 10:23
@roxblnfk roxblnfk changed the title (削除) fix(SelectQuery): reject non-positive chunk size in runChunks() (削除ここまで) (追記) feat(SelectQuery): type runChunks() chunk size as int<1, max> (追記ここまで) Jun 11, 2026
@roxblnfk roxblnfk force-pushed the bugfix/runchunks-reject-non-positive-limit branch from b2d4cad to ff647ca Compare June 11, 2026 10:30
@roxblnfk roxblnfk changed the title (削除) feat(SelectQuery): type runChunks() chunk size as int<1, max> (削除ここまで) (追記) feat(SelectQuery): refine Psalm integer types on query bounds (追記ここまで) Jun 11, 2026
Express numeric bounds via Psalm types so static analysis flags invalid values at call sites:
- runChunks() chunk size as int<1, max> (a non-positive value never advances the offset and spins in an endless loop);
- getLimit() / getOffset() as int<0, max>|null;
- count() as int<0, max> (a row count is never negative).
Also drop the redundant `psalm-` prefix from the existing non-empty-string column/method hints: plain `@param` advanced types are now broadly supported (Psalm, PHPStan, PhpStorm).
Return-type refinements only; LessSpecificReturnStatement / MoreSpecificReturnType are already suppressed project-wide, and setter params are left intact to preserve the PaginableInterface contract.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@roxblnfk roxblnfk force-pushed the bugfix/runchunks-reject-non-positive-limit branch from ff647ca to 39d0018 Compare June 11, 2026 10:39
@roxblnfk roxblnfk merged commit 2cae328 into 2.x Jun 11, 2026
31 checks passed
@roxblnfk roxblnfk deleted the bugfix/runchunks-reject-non-positive-limit branch June 11, 2026 11:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

AltStyle によって変換されたページ (->オリジナル) /