1 <?php declare(strict_types=1);
3 namespace PhpParser\ErrorHandler;
6 use PhpParser\ErrorHandler;
9 * Error handler that collects all errors into an array.
11 * This allows graceful handling of errors.
13 class Collecting implements ErrorHandler
15 /** @var Error[] Collected errors */
18 public function handleError(Error $error) {
19 $this->errors[] = $error;
23 * Get collected errors.
27 public function getErrors() : array {
32 * Check whether there are any errors.
36 public function hasErrors() : bool {
37 return !empty($this->errors);
41 * Reset/clear collected errors.
43 public function clearErrors() {