On 29/01/2025 15:12, Tim Düsterhus wrote:
Hi
Volker and I would like to start discussion on our RFC to allow
"Marking return values as important (#[\NoDiscard])".
Please find the following resources for your reference:
- RFC: https://wiki.php.net/rfc/marking_return_value_as_important
- Implementation: https://github.com/php/php-src/pull/17599
Best regards
Tim Düsterhus
Apologies if this has already been brought up; I haven't read the entire
thread, but isn't the entire premise of this RFC based on a falsehood?
>This kind of “partial success” can only be reliably communicated by
means of a return value
Exceptions are objects, so you can attach whatever additional
information you wish to that object.
Perhaps the word "reliably" is doing a lot of heavy lifting in that
sentence, but if you would refute me (which presumably you will), then I
think this needs to be explained in better detail in the RFC, because it
looks to me that exploiting object properties is just as viable as
returning something, and probably preferred, since this solves your
problem of the user not handling the failure.
Cheers,
Bilge