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

Don't prevent checking for curl_init() false returns #3409

Merged
merged 3 commits into from
Sep 6, 2024

Conversation

tscni
Copy link
Contributor

@tscni tscni commented Sep 6, 2024

@phpstan-bot
Copy link
Collaborator

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.

@tscni tscni changed the base branch from 2.0.x to 1.12.x September 6, 2024 10:19
@tscni tscni marked this pull request as draft September 6, 2024 10:46
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
Comment on lines -1363 to -1366
-
class: PHPStan\Type\Php\CurlInitReturnTypeExtension
tags:
- phpstan.broker.dynamicFunctionReturnTypeExtension
Copy link
Contributor Author

@tscni tscni Sep 6, 2024

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

@tscni tscni marked this pull request as ready for review September 6, 2024 15:05
@phpstan-bot
Copy link
Collaborator

This pull request has been marked as ready for review.

@ondrejmirtes ondrejmirtes merged commit 3592cf0 into phpstan:1.12.x Sep 6, 2024
486 of 500 checks passed
@ondrejmirtes
Copy link
Member

Thank you!

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.

curl_init() Negated boolean expression is always false.
3 participants