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

PHPStan seems to think error_log is pure but it's not #10437

Closed
InvisibleSmiley opened this issue Jan 15, 2024 · 2 comments
Closed

PHPStan seems to think error_log is pure but it's not #10437

InvisibleSmiley opened this issue Jan 15, 2024 · 2 comments
Labels
Milestone

Comments

@InvisibleSmiley
Copy link

Bug report

If a call to error_log failed because it was unable to write to a file, the identical call might succeed later if in between the situation concerning the target file changed. Hence, error_log should be considered impure.

Unfortunately PHPStan considers all functions that return a value to be pure by default. I strongly disagree but that's not what this particular issue is about.

In my example I even reset the stat cache. I think this sufficed in the past so this might be a regression.

For the time being my workaround is to put rememberPossiblyImpureFunctionValues: false in the config. I might actually keep that there irrespective of whether this issue will be fixed or not.

Code snippet that reproduces the problem

https://phpstan.org/r/26928297-bb3d-450a-98d3-b2eb62208606

Expected output

No warnings/errors

Did PHPStan help you today? Did it make you happy in any way?

No response

@ondrejmirtes
Copy link
Member

Fixed phpstan/phpstan-src#2884

Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants