TryCatch.php 1.1 KB

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