TryCatch.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php declare(strict_types=1);
  2. namespace PhpParser\Node\Stmt;
  3. use PhpParser\Node;
  4. class TryCatch extends Node\Stmt {
  5. /** @var Node\Stmt[] Statements */
  6. public array $stmts;
  7. /** @var Catch_[] Catches */
  8. public array $catches;
  9. /** @var null|Finally_ Optional finally node */
  10. public ?Finally_ $finally;
  11. /**
  12. * Constructs a try catch node.
  13. *
  14. * @param Node\Stmt[] $stmts Statements
  15. * @param Catch_[] $catches Catches
  16. * @param null|Finally_ $finally Optional finally node
  17. * @param array<string, mixed> $attributes Additional attributes
  18. */
  19. public function __construct(array $stmts, array $catches, ?Finally_ $finally = null, array $attributes = []) {
  20. $this->attributes = $attributes;
  21. $this->stmts = $stmts;
  22. $this->catches = $catches;
  23. $this->finally = $finally;
  24. }
  25. public function getSubNodeNames(): array {
  26. return ['stmts', 'catches', 'finally'];
  27. }
  28. public function getType(): string {
  29. return 'Stmt_TryCatch';
  30. }
  31. }