Fix counting *scanf() format string placeholders#5594
Open
hakre wants to merge 2 commits intophpstan:2.1.xfrom
Open
Fix counting *scanf() format string placeholders#5594hakre wants to merge 2 commits intophpstan:2.1.xfrom
*scanf() format string placeholders#5594hakre wants to merge 2 commits intophpstan:2.1.xfrom
Conversation
57da830 to
5742f2b
Compare
sscanf/fscanf format string placeholderssscanf/fscanf format string placeholders
Collaborator
|
This pull request has been marked as ready for review. |
staabm
reviewed
May 6, 2026
staabm
reviewed
May 6, 2026
sscanf/fscanf format string placeholders*scanf() format string placeholders
Author
|
Do you know by chance why https://github.com/phpstan/phpstan-src/actions/runs/25431166468/job/74597885107 keeps failing on my changes? I'd like to better understand @staabm |
Contributor
we see the same errors on others PRs targeting 2.1.x -> this means these errors are not related to your PR |
Additional by-catch fix of a variable misnomer in 023fa08 ("Fix printf parameters rule", 2017-04-02) spotted during review.
4bd3eca to
04f1759
Compare
Update PrintfHelper.php to make
public function getScanfPlaceholdersCount(string $format): ?int`
return the sscanf() vetted number of placeholders that return/assign
conversions.
Addresses long-standing regressions reported originally in
[phpstan-10260].
References:
- [phpstan-10260]
- phpstan/phpstan#10260 (comment)
- [phpstan-src-5591]
- [phpstan-14567]
- https://3v4l.org/WR85Q
[phpstan-10260]: phpstan/phpstan#10260
[phpstan-src-5591]: phpstan#5591
[phpstan-14567]: phpstan/phpstan#14567
staabm
reviewed
May 7, 2026
| use const PHP_INT_MAX; | ||
| use const PHP_VERSION_ID; | ||
|
|
||
| #[CoversMethod(PrintfHelper::class, 'getScanfPlaceholdersCount')] |
Contributor
There was a problem hiding this comment.
we don't use Covers*/Uses* attributes. please remove them.
staabm
reviewed
May 7, 2026
| return new PhpVersion($versionId); | ||
| } | ||
|
|
||
| public static function dataLegacyVersionIds(): Generator |
Contributor
There was a problem hiding this comment.
what is this complicated method doing? couldn't we just have a data-provider which returns a few representative "hard-coded" data-pairs ?
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.
Update PrintfHelper.php:
Make
public function getScanfPlaceholdersCount(string $format): ?intreturning the sscanf() vetted number of placeholders that give/return/assign conversions.refs:
sscanf/fscanfformat string at NUL byte before counting placeholders #5591