+
Skip to content

Incorrect number of sscanf placeholders detected (again) #10260

@carina-deaconu

Description

@carina-deaconu

Bug report

I found another case regarding #64 which has been solved in 2017, so I'll copy the description there:

sscanf has an "additional" way of specifying strings using regex-like character classes. It's handy when parsing strings with non-space separators. Not all these character classes are not correctly detected by PHPStan.

sscanf call like the following one throws Call to sscanf contains 1 placeholder, 3 values given.

sscanf('appletone_day_1', '%*[a-z]_day%s', $day_number);

but it's actually a correct sscanf call, see https://3v4l.org/PNEok (also explains the character classes thing)

Code snippet that reproduces the problem

https://phpstan.org/r/e7d60aa1-3a26-403a-a113-eb520de5bfc9

Expected output

No issue should be reported.

Did PHPStan help you today? Did it make you happy in any way?

Yes! It is a really great and interesting tool I'm excited about playing with when testing my code. It detects overlooked bugs like undefined variables and points to dead/unused code which we happily remove after.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载