-
Notifications
You must be signed in to change notification settings - Fork 79
Support parsing multiple exception types in catch clauses #103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Any update on this? |
I've filed an issue with php-langspec as this is not currently documented and tested upstream: php/php-langspec#216 |
My thoughts on solving this: Add a new property to the tolerant-php-parser object representing the CatchClause->remainingQualifiedNameList would either be null or begin with
|
More than a year a still no fix 😢 |
@Zerquix18 Feel free to file a pr :) |
@Zerquix18 Seriously, whining won't make it be fixed any faster. A PR will. This project is driven by community contributions. |
Add a new array `otherQualifiedNameList` alongside qualifiedName to `CatchClause`. (Contains remaining `Token`s and `QualifiedName`s) (This design breaks backwards compatibility as little as possible) - A future backwards incompatible release should merge the two properties into `qualifiedNameList`, or something along those lines. Add a new helper method to parse the catch list. - The new helper is required because `tests/cases/php-langspec/exception_handling/odds_and_ends.php` should not fail because `catch (int $e)` is **syntactically** valid php (in 7.x), i.e. `php --syntax-check` doesn't reject it.
Add a new array `otherQualifiedNameList` alongside qualifiedName to `CatchClause`. (Contains remaining `Token`s and `QualifiedName`s) (This design breaks backwards compatibility as little as possible) - A future backwards incompatible release should merge the two properties into `qualifiedNameList`, or something along those lines. Add a new helper method to parse the catch list. - The new helper is required because `tests/cases/php-langspec/exception_handling/odds_and_ends.php` should not fail because `catch (int $e)` is **syntactically** valid php (in 7.x), i.e. `php --syntax-check` doesn't reject it.
Fixes #103: Support parsing multiple exception types
PHP 7.1 introduced support for catching multiple exception types:
https://wiki.php.net/rfc/multiple-catch
We should handle this condition on the parser by parsing as a delimited list of qualified names, where the delimiter is the
TokenKind::BarToken
, and we should be able to reuse the logic fromparseQualifiedNameList
The text was updated successfully, but these errors were encountered: