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

Fix wrong fread() length parameter type and return type #3105

Merged
merged 1 commit into from
May 30, 2024

Conversation

thg2k
Copy link
Contributor

@thg2k thg2k commented May 29, 2024

This PR addresses two issues with the fread() signature:

  1. The length parameter requires int<1, max> at engine level instead of int<0, max>.

  2. The return type could never be false until php 7.4.0 (unless bogus parameters are passed, but that does not count). Even in case of stream failure. Since php 7.4.0, it can indeed return false for example when reading from a valid stream, i.e. a failed socket.

About the return type, i'm not completely sure we should fix this. For forward compatibility, in case of language level < 7.4.x, it might be good that phpstan warns about the possibility of false return value.

Thoughts?

@thg2k thg2k force-pushed the pr/fread_fixup branch from f0761bc to 37de213 Compare May 29, 2024 16:13
@thg2k
Copy link
Contributor Author

thg2k commented May 29, 2024

For the test failure, I believe I cannot use PHP_VERSION_ID inside the data files to determine the correct assertType, right? So instead of duplicating the whole data file from filesystem-function.php to filesystem-function74.php, how about I simply skip the test with PHP < 7.4?

Verified

This commit was signed with the committer’s verified signature.
thg2k Giovanni Giacobbi
@thg2k thg2k force-pushed the pr/fread_fixup branch from 37de213 to 6866827 Compare May 29, 2024 17:48
@ondrejmirtes ondrejmirtes merged commit 43d3ac4 into phpstan:1.11.x May 30, 2024
439 of 445 checks passed
@ondrejmirtes
Copy link
Member

Thank you.

@thg2k thg2k deleted the pr/fread_fixup branch June 10, 2024 14:41
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.

None yet

2 participants