Skip to content

Support of printf with dynamic width#2543

Merged
ondrejmirtes merged 1 commit intophpstan:1.10.xfrom
kukulich:master
Jul 24, 2023
Merged

Support of printf with dynamic width#2543
ondrejmirtes merged 1 commit intophpstan:1.10.xfrom
kukulich:master

Conversation

@kukulich
Copy link
Copy Markdown
Contributor

@phpstan-bot
Copy link
Copy Markdown
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
Copy Markdown
Collaborator

This pull request has been marked as ready for review.

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

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

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
Copy Markdown
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

Development

Successfully merging this pull request may close these issues.

Printf with width format is not recognized

4 participants