Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support of printf with dynamic width #2543

Merged
merged 1 commit into from Jul 24, 2023
Merged

Conversation

kukulich
Copy link
Contributor

@phpstan-bot
Copy link
Collaborator

You've opened the pull request against the latest branch 1.11.x. If your code is relevant on 1.10.x and you want it to be released sooner, please rebase your pull request and change its target to 1.10.x.

@kukulich kukulich changed the base branch from 1.11.x to 1.10.x July 24, 2023 13:19
@kukulich kukulich marked this pull request as ready for review July 24, 2023 13:34
@phpstan-bot
Copy link
Collaborator

This pull request has been marked as ready for review.

@ondrejmirtes ondrejmirtes merged commit 655e028 into phpstan:1.10.x Jul 24, 2023
410 checks passed
@@ -116,7 +116,7 @@ private function getPlaceholdersCount(string $functionName, string $format): int

$specifiers = sprintf($specifiers, $addSpecifier);

$pattern = '~(?<before>%*)%(?:(?<position>\d+)\$)?[-+]?(?:[ 0]|(?:\'[^%]))?-?\d*(?:\.\d*)?' . $specifiers . '~';
$pattern = '~(?<before>%*)%(?:(?<position>\d+)\$)?[-+]?(?:(?:[ 0]|(?:\'[^%]))(?<width>\*)?)?-?\d*(?:\.\d*)?' . $specifiers . '~';

Choose a reason for hiding this comment

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

Looking at this regex, I see the precision doesn't allow for a * either.

Sorry for not testing that case before opening the issue 😖

From the doc:

Note: If the period is specified without an explicit value for precision, 0 is assumed. If * is used, the precision is supplied as an additional integer value preceding the one formatted by the specifier.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@fmarchalemisys Please open new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants