Skip to content

Implement IniGetReturnTypeExtension#2362

Merged
ondrejmirtes merged 2 commits intophpstan:1.10.xfrom
staabm:ini-get
Apr 24, 2023
Merged

Implement IniGetReturnTypeExtension#2362
ondrejmirtes merged 2 commits intophpstan:1.10.xfrom
staabm:ini-get

Conversation

@staabm
Copy link
Copy Markdown
Contributor

@staabm staabm commented Apr 24, 2023

@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.

@staabm staabm changed the base branch from 1.11.x to 1.10.x April 24, 2023 09:24
@staabm staabm marked this pull request as ready for review April 24, 2023 09:32
@phpstan-bot
Copy link
Copy Markdown
Collaborator

This pull request has been marked as ready for review.

$results = [];
foreach ($argType->getConstantStrings() as $constantString) {
if (!array_key_exists($constantString->getValue(), $types)) {
continue;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

So what's the default return type? If we encounter 'unknown'|'max_execution_time', the return type from this extension will be wrong.

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.

good catch

@ondrejmirtes ondrejmirtes merged commit 7c5bbbf into phpstan:1.10.x Apr 24, 2023
@ondrejmirtes
Copy link
Copy Markdown
Member

Thank you.

@ondrejmirtes
Copy link
Copy Markdown
Member

Although I don't understand how it's gonna help #2358 (comment) because for that key it's still gonna be string|false AFAIK.

@staabm
Copy link
Copy Markdown
Contributor Author

staabm commented Apr 24, 2023

I think precision can be added to the type list to make it return a numeric-string:

$ php -r 'var_dump(ini_get("precision"));'
string(2) "14"

$  php -n -r 'var_dump(ini_get("precision"));'
string(2) "14"

but thats something I would expect to be part of #2358

see also https://www.php.net/manual/en/ini.core.php#ini.precision

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.

ini_get() analysis should be aware of whether an option exists or not

3 participants