No Description

TryCatch.php 1.1KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. namespace PhpParser\Node\Stmt;
  3. use PhpParser\Node;
  4. use PhpParser\Error;
  5. /**
  6. * @property Node[] $stmts Statements
  7. * @property Catch_[] $catches Catches
  8. * @property Node[] $finallyStmts Finally statements
  9. */
  10. class TryCatch extends Node\Stmt
  11. {
  12. /**
  13. * Constructs a try catch node.
  14. *
  15. * @param Node[] $stmts Statements
  16. * @param Catch_[] $catches Catches
  17. * @param Node[] $finallyStmts Finally statements (null means no finally clause)
  18. * @param array|null $attributes Additional attributes
  19. */
  20. public function __construct(array $stmts, array $catches, array $finallyStmts = null, array $attributes = array()) {
  21. if (empty($catches) && null === $finallyStmts) {
  22. throw new Error('Cannot use try without catch or finally');
  23. }
  24. parent::__construct(
  25. array(
  26. 'stmts' => $stmts,
  27. 'catches' => $catches,
  28. 'finallyStmts' => $finallyStmts,
  29. ),
  30. $attributes
  31. );
  32. }
  33. }