-
Notifications
You must be signed in to change notification settings - Fork 7.8k
PHP 8.5 #[NoDiscard]
should probably not be on flock()
#18235
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
Comments
#[NoDiscard]
should probably not be on flock()
Yeah, it would need some sort of conditional NoDiscard, but we don't have that. "NoDiscard unless parameter is X" or something. Like
But as a short-term measure we probably should remove it now. |
@TimWolla Do you want to take care about it? |
And requiring such a functionality is probably an indicator of a questionable API design. But indeed, we did not realize that ignoring the result for The attribute being on Alternatively we could perhaps add a new:
function with a more misuse-resistant API that would also be easily polyfillable. |
That's not really an alternative to the pain imposed on existing code bases, since those would still need to be updated to accommodate for the new warning. |
I don't think it's questionable API design to have some cases of an API where the return value is not necessarily important. I also disagree with a dedicated |
Yes, I'll handle that, part of the RFC duty. It would also require a new function in zend_test, since some of the “native function” tests use For proper process, I also just sent an email to Internals, pointing towards the issue, allowing folks to object / force a follow-up vote. It should show up somewhere here once externals catches up: https://externals.io/message/126580 |
Maybe revert the whole It not only cannot handle conditional usecases based on params, but in a long term, the result might be not needed as some functions might starting to throw which can depend on the handle, thus the conditionality can depend not only on param, but also on handle settings (like we have for PDO already). I also have a small question. I know the |
Description
The following code:
Resulted in this output:
But I expected this output instead:
While
flock()
forLOCK_EX
/LOCK_SH
operations should definitely be checked for safety, the addition of the#[NoDiscard]
attribute there is a bit unfortunate as theLOCK_UN
operation doesn't really require checking.symfony/symfony#60128 is a first symptom of this problem, and I am afraid more will come through. As many projects turn warnings into exceptions this is in practice very close to a BC break.
The new attribute makes sense for cases where not using the return value is definitely going to cause a bug, but for flock it's currently more a strictness check than catching bugs.
PHP Version
8.5
Operating System
No response
The text was updated successfully, but these errors were encountered: