Heya,

I voted "NO" due to previous discussion. TL;DR: this is FAR off the 80/20
use-case for a language syntax change.

C&P from my answer elsewhere:

The following typical example is something REALLY rare, and requiring a
parser change for it seems excessive:

    try {
        // ...
    } catch (InvalidArgumentException $e) {
        // same handling
    } catch (PDOException $e) {
        // same handling
    } catch (BadMethodCallException $e) {
        // same handling
    }

These 3 exceptions usually result in separate handling anyway. If same
handling is needed, you can as usual extract a private method  (if you are
in a class) and deal with it there:

    try {
        // ...
    } catch (InvalidArgumentException $e) {
        $this->sameHandling($e);
    } catch (PDOException $e) {
        $this->sameHandling($e);
    } catch (BadMethodCallException $e) {
        $this->sameHandling($e);
    }

    private function sameHandling(Throwable $caught)
    {
        // same handling
    }

Still, even in this case, I'd flag it up in a code review, as same handling
for 3 different exception types generally (not always) means something is
really wrong.

So we are building a feature for a 1% case that, while simple to implement
at parser-level in PHP, requires changes in all userland libraries that do
parsing or rely on the AST.

Cheers,

Marco Pivetta

http://twitter.com/Ocramius

http://ocramius.github.com/

On 18 April 2016 at 01:08, Dan Ackroyd <dan...@basereality.com> wrote:

> I voted yes.
>
> It's really not that common that I have to do stuff in exception
> handling, when I do need to do some clearing up, or checking to see if
> the operation that threw the exception needs to be re-tried, having to
> repeat that code in all of the catch statements that need it, is just
> nasty duplication.
>
> Although it's a small change, having this is a very nice small
> improvement that doesn't break anyone's existing code.
>
> Thanks for putting it forward.
>
> cheers
> Dan
>
>
> On 17 April 2016 at 17:51, Bronisław Białek <afte...@gmail.com> wrote:
> > Hi Internals,
> >
> > We've opened the vote on https://wiki.php.net/rfc/multiple-catch
> > Voting will end on 2015-05-01
> >
> > --
> > Regards,
> > Bronisław Białek.
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Reply via email to