FAQ

On 9 March 2016 at 14:24, Pierrick Charron 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/

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 14 of 19 | next ›
Discussion Overview
groupphp-internals @
categoriesphp
postedMar 8, '16 at 9:42p
activeMar 19, '16 at 9:09p
posts19
users10
websitephp.net

People

Translate

site design / logo © 2019 Grokbase