Catch_.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php declare(strict_types=1);
  2. namespace PhpParser\Node\Stmt;
  3. use PhpParser\Node;
  4. use PhpParser\Node\Expr;
  5. class Catch_ extends Node\Stmt {
  6. /** @var Node\Name[] Types of exceptions to catch */
  7. public array $types;
  8. /** @var Expr\Variable|null Variable for exception */
  9. public ?Expr\Variable $var;
  10. /** @var Node\Stmt[] Statements */
  11. public array $stmts;
  12. /**
  13. * Constructs a catch node.
  14. *
  15. * @param Node\Name[] $types Types of exceptions to catch
  16. * @param Expr\Variable|null $var Variable for exception
  17. * @param Node\Stmt[] $stmts Statements
  18. * @param array<string, mixed> $attributes Additional attributes
  19. */
  20. public function __construct(
  21. array $types, ?Expr\Variable $var = null, array $stmts = [], array $attributes = []
  22. ) {
  23. $this->attributes = $attributes;
  24. $this->types = $types;
  25. $this->var = $var;
  26. $this->stmts = $stmts;
  27. }
  28. public function getSubNodeNames(): array {
  29. return ['types', 'var', 'stmts'];
  30. }
  31. public function getType(): string {
  32. return 'Stmt_Catch';
  33. }
  34. }