Uh oh!
There was an error while loading. Please reload this page.
Use RETURN_THROWS() macro when an exception is thrown - #5036
Conversation
37039d0 to
8b7bbceCompareUh oh!
There was an error while loading. Please reload this page.
8b7bbce to
0dbeed0Compare
nikic
left a comment
There was a problem hiding this comment.
Would be great if we can get this used comprehensively at least for zpp return, to avoid coding style inconsistencies. Will probably take a while until this is used everywhere it should be used...
kocsismate
commented
Dec 30, 2019
My plan is to do the migration for ZPP and for some exceptions (after If you agree, I can commit the most straightforward changes directly. |
nikic
commented
Dec 30, 2019
Yeah, committing those directly is fine. Please add a |
Thanks for the hint, I was actually wondered how to avoid using this macro multiple times in the same code branch. So the final version of |
nikic
commented
Dec 30, 2019
It would be fairly unusual to return a void value, I'm not sure it's permitted at all. |
Ok, I didn't know it's possible in this form (btw my version also worked for me). |
0dbeed0 to
8b03a4fComparenikic
commented
Jan 3, 2020
zend_fetch_resource() is another candidate for mass conversion. |
Thanks for the idea! I was about to ask you for suggestions, so feel free to write me should a candidate come to your mind. Would |
nikic
commented
Jan 3, 2020
@kocsismate Yeah, try_convert_to_string() throws iff it returns null. |
kocsismate
commented
Jan 3, 2020
Just one more question: should I also include |
nikic
commented
Jan 3, 2020
Yes. _ex allows NULL, 2 checks for two resource types (generally persistent + non-persistent). In all cases the deciding factor whether it throws or not is whether the resource name is passed. |
kocsismate
commented
Jan 3, 2020
Thanks!
Yep, I noticed this after I finished the migration for |
Let's introduce a macro in order to indicate that an exception was thrown previously as proposed by Nikita in #4994 (review) (Click "Show resolved").
It made sense for me to use this macro even when the exception was thrown one line before, but I can also change them back to normal
returns.