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

infer non-falsy-string in sscanf() #1662

Merged
merged 1 commit into from Sep 1, 2022

Conversation

staabm
Copy link
Contributor

@staabm staabm commented Aug 30, 2022

No description provided.

@staabm staabm marked this pull request as ready for review August 30, 2022 07:31
@staabm staabm force-pushed the non-falsy-sscanf branch 2 times, most recently from 9ccd893 to 3141f68 Compare August 31, 2022 07:10
function fooo() {
function fooo(string $s) {
// %0s returns the whole string
assertType('array{non-empty-string|null}|null', sscanf( "0" , "%0s"));
assertType('array{non-empty-string|null}|null', sscanf( "123456" , "%0s"));
Copy link
Contributor Author

@staabm staabm Aug 31, 2022

Choose a reason for hiding this comment

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

actually for a non-falsy-string $string this line could lead to a more precise 'array{non-falsy-string|null}|null', but I feel like %0s as a format is more or less a theoretical thing.. never seen it used anywhere.. I think people would use %s instead.

I figured its not important enough to complicate the extension for it

@ondrejmirtes ondrejmirtes merged commit 5e54dbd into phpstan:1.8.x Sep 1, 2022
@ondrejmirtes
Copy link
Member

Thank you!

@staabm staabm deleted the non-falsy-sscanf branch September 1, 2022 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants