On 9 March 2016 at 14:24, Pierrick Charron <pierr...@adoy.net> wrote:
>
> The thing I don't like about this approach is that I have to read the code
> and double check to make sure that the catch statement call the same method.
> For the amount of work that needs to be done in the Engine (see the patch
> attached to the RFC) this is far more readable and it is clear that the
> code to handle those 3 exceptions is the exact same one. And if the code of
> handleFailure is small you can even put it at this single place.
>
> public function stuff()
> {
>     try {
>         $this->willFail();
>     } catch (FirstException | SecondException | ThirdException $e) {
>         $this->handleFailure($e);
>     }
> }
>
>
I'd still have to write 3 test cases anyway: no real amount of code-savings
there.

I still think the first solution is as readable as the one you proposed
there.
The change in the PHP engine might be trivial, but the syntax change from a
userland perspective is a mess (tooling, pretty much anything that relies
on an AST parser needs changes there).
Do not underestimate language changes as a php-core only issue.

Marco Pivetta

http://twitter.com/Ocramius

http://ocramius.github.com/

Reply via email to