Skip to content

setlocale() can take as argument 0 and NULL#351

Merged
ondrejmirtes merged 2 commits intophpstan:masterfrom
peter-gribanov:setlocale
Oct 21, 2020
Merged

setlocale() can take as argument 0 and NULL#351
ondrejmirtes merged 2 commits intophpstan:masterfrom
peter-gribanov:setlocale

Conversation

@peter-gribanov
Copy link
Copy Markdown
Contributor

https://www.php.net/manual/en/function.setlocale.php

If locale is NULL or the empty string "", the locale names will be set from the values of environment variables with the same names as the above categories, or from "LANG".
If locale is "0", the locale setting is not affected, only the current setting is returned.

@ondrejmirtes
Copy link
Copy Markdown
Member

Is it supposed to be integer 0 or string "0"?

@peter-gribanov
Copy link
Copy Markdown
Contributor Author

Is a integer, not a string.

@peter-gribanov
Copy link
Copy Markdown
Contributor Author

peter-gribanov commented Oct 19, 2020

No, though. Wait. It seems i'm wrong.

@peter-gribanov
Copy link
Copy Markdown
Contributor Author

It is not obvious to me from the documentation which data type should be used. Integer is most commonly used. It's not obvious to me in the source either. Both options work the same way.

@ondrejmirtes
Copy link
Copy Markdown
Member

Yeah, these functions are weird, the documentation talks about string only though. I'd accept a PR that changes the type to string|null.

@peter-gribanov
Copy link
Copy Markdown
Contributor Author

@ondrejmirtes please review

@ondrejmirtes ondrejmirtes merged commit 912e66b into phpstan:master Oct 21, 2020
@ondrejmirtes
Copy link
Copy Markdown
Member

Thank you!

@peter-gribanov peter-gribanov deleted the setlocale branch October 21, 2020 15:33
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