ovr / phpsa

Smart/Static Analyzer(sis) for PHP :bowtie::neckbeard:
Other
638 stars 77 forks source link

Error on combined exceptions #358

Closed davidsneighbour closed 4 years ago

davidsneighbour commented 5 years ago

Using

PHP Smart Analyzer version 0.6.2 #v11.2.107-2027-ga1808b593a6e

the following code

try {
... some code ...
} catch (SentryDisabled | Raven_Exception $eException) {
... some code ...
}

throws an error

Syntax error:  Syntax error, unexpected '|', expecting T_VARIABLE on line 126 in ... 

PHP Version:

PHP 7.2.15-0ubuntu0.18.10.1 (cli) (built: Feb  8 2019 14:54:22) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.15-0ubuntu0.18.10.1, Copyright (c) 1999-2018, by Zend Technologies
    with Xdebug v2.6.0, Copyright (c) 2002-2018, by Derick Rethans

In production this does not result in an error but works as expected (either one of the exceptions is catched). I am not sure if it was possible before PHP7.2, but in 7.2 definitely is valid code.

kilgaloon commented 5 years ago

Hey @davidsneighbour

Are you using code from master or release tag one?

Multi exception catch is added in 7.1.

davidsneighbour commented 5 years ago

I am using the latest phar release 0.6.2.