Skip to content

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

Merged
ondrejmirtes merged 1 commit intophpstan:1.8.xfrom
staabm:non-falsy-sscanf
Sep 1, 2022
Merged

infer non-falsy-string in sscanf()#1662
ondrejmirtes merged 1 commit intophpstan:1.8.xfrom
staabm:non-falsy-sscanf

Conversation

@staabm
Copy link
Copy Markdown
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(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
Copy Markdown
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
Copy Markdown
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

Development

Successfully merging this pull request may close these issues.

2 participants