Resolve the printf format parser's PHP version check from Scope::getPhpVersion() - #6536
Merged
staabm merged 1 commit intoSep 22, 2026
Conversation
…hpVersion() PrintfFormatParser asked a DI-injected PhpVersion whether the h/H specifiers are supported. That object only knows the single version configured in phpstan.neon, so it ignored both PHP_VERSION_ID narrowing in the analysed code and a configured phpVersion range. parse() now takes the call site's PhpVersions, which every caller reads from Scope::getPhpVersion(), and treats the specifiers as valid unless the analysed range certainly predates PHP 8.0. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
staabm
force-pushed
the
create-pull-request/printf-format-parser-scope-php-version
branch
from
September 22, 2026 13:16
b4545dc to
1420645
Compare
staabm
deleted the
create-pull-request/printf-format-parser-scope-php-version
branch
September 22, 2026 13:36
phpstan-bot
added a commit
to phpstan-bot/phpstan-src
that referenced
this pull request
Sep 22, 2026
The printf format parser change was split off into phpstan#6536, which has since been merged into the base branch. Reverting it on this branch therefore undid already-merged work instead of separating it, so the parser keeps parse(string $format, PhpVersions $phpVersions) and the rules keep passing Scope::getPhpVersion(). PrintfFunctionThrowTypeExtension keeps this pull request's own change: its throwsValueErrorForInternalFunctions() check resolved from the Scope. This reverts commit fba0257. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
staabm
pushed a commit
to phpstan-bot/phpstan-src
that referenced
this pull request
Sep 22, 2026
The printf format parser change was split off into phpstan#6536, which has since been merged into the base branch. Reverting it on this branch therefore undid already-merged work instead of separating it, so the parser keeps parse(string $format, PhpVersions $phpVersions) and the rules keep passing Scope::getPhpVersion(). PrintfFunctionThrowTypeExtension keeps this pull request's own change: its throwsValueErrorForInternalFunctions() check resolved from the Scope. This reverts commit fba0257. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
PrintfFormatParserasked a DI-injected PhpVersion whether the h/H specifiers are supported. That object only knows the single version configured in phpstan.neon, so it ignored bothPHP_VERSION_IDnarrowing in the analysed code and a configured phpVersion range.parse()now takes the call site's PhpVersions, which every caller reads fromScope::getPhpVersion(), and treats the specifiers as valid unless the analysed range certainly predates PHP 8.0.