-
Notifications
You must be signed in to change notification settings - Fork 504
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
Don't prevent checking for curl_init() false returns #3409
Conversation
You've opened the pull request against the latest branch 2.0.x. PHPStan 2.0 is not going to be released for months. If your code is relevant on 1.12.x and you want it to be released sooner, please rebase your pull request and change its target to 1.12.x. |
When we decide to not ignore curl memory allocation & initialization issues entirely, this leaves us with the edge case of a zero byte input or a huge URL which might return false or never. Both seem similarly unlikely, making the return type extension not quite worthwhile.
The function map would cover them
- | ||
class: PHPStan\Type\Php\CurlInitReturnTypeExtension | ||
tags: | ||
- phpstan.broker.dynamicFunctionReturnTypeExtension |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When we no longer ignore curl_init()
memory allocation & initialization issues, this extension becomes mostly useless.
It would really only handle the following
- If the input contains
\0
it will always return false / never - If the input is really huge it will likely return false
- If the input is an invalid URL or uses the
file://
scheme it might return false on PHP 7
These are all very unlikely edge-cases, thus it seemed more reasonable to move the return type definition to the function map.
In short: curl_init()
will now always return (resource|false)
or (CurlHandle|false)
.
This pull request has been marked as ready for review. |
Thank you! |
Fixes phpstan/phpstan#11640