Repository navigation
Re-enable and clean up PHPStan level 5 'int given, string expected' warnings - #1620
Merged
Merged
Conversation
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
approved these changes
Sep 3, 2026
cpeel
left a comment
Member
There was a problem hiding this comment.
Added one comment -- I'm fine with what you have but will wait until you reply before merging to confirm.
(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
approved these changes
Sep 3, 2026
cpeel
approved these changes
Sep 3, 2026
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.
No description provided.