xp-framework / compiler

Compiles future PHP to today's PHP.
19 stars 0 forks source link

Allow empty catch type to catch all exceptions #46

Closed thekid closed 6 years ago

thekid commented 6 years ago

Form without variable

Will catch but not assign any variable:

try {
  …
} catch (IllegalArgumentException) {
  // Handle exception
}

Form without type

Will catch all exceptions - a shorthand for catch (\Throwable $e):

try {
  …
} catch ($e) {
  // Handle exception
}

Anonymous catch

Will catch all exceptions and not assign any variable:

try {
  …
} catch {
  // Handle
}

Related

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/try...catch https://wiki.php.net/rfc/anonymous_catch - allows omitting variable if not needed.

thekid commented 6 years ago

47 merged instead