Skip to content

Re-enable and clean up PHPStan level 5 'int given, string expected' warnings - #1620

Merged
cpeel merged 12 commits into
DistributedProofreaders:masterfrom
bpfoley:level5-3
Sep 3, 2026
Merged

cpeel merged 12 commits into
DistributedProofreaders:masterfrom
bpfoley:level5-3

Conversation

@bpfoley

@bpfoley bpfoley commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

This is just the same as a `User.u_id` which is an `int`.
Fix the misleading defensive uses of `intval(...)` and `%s`
when preparing SQL.

Fixes 13/34
But the type for the two arguments must match.
The trick is to use a template with the type constraint you want.
(As should have been obvious from the SQL queries). `news_page_ids`
on the other hand are strings and are hardcoded as the keys
in `$NEWS_PAGES` in `pinc/site_news.inc`
...by using the more approriate (and compact) `sprintf` instead.

@cpeel cpeel left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added one comment -- I'm fine with what you have but will wait until you reply before merging to confirm.

Comment thread pinc/misc.inc
(Which, of course, are HTML safe by their nature)

Quells a few PHPStan int used where string expected warnings
(After I made the same typo myself. I guess we expect to see enums
everywhere...)
This allows us to catch several cases (and the fallout upstream in
the callers) where a function really only needed an int arg.
@cpeel
cpeel merged commit 8493016 into DistributedProofreaders:master Sep 3, 2026
12 checks passed
@bpfoley
bpfoley deleted the level5-3 branch September 3, 2026 16:56
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