Mercurial > hg > isophonics-drupal-site
comparison vendor/nikic/php-parser/lib/PhpParser/ErrorHandler/Collecting.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children | 5fb285c0d0e3 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4c8ae668cc8c |
---|---|
1 <?php | |
2 | |
3 namespace PhpParser\ErrorHandler; | |
4 | |
5 use PhpParser\Error; | |
6 use PhpParser\ErrorHandler; | |
7 | |
8 /** | |
9 * Error handler that collects all errors into an array. | |
10 * | |
11 * This allows graceful handling of errors. | |
12 */ | |
13 class Collecting implements ErrorHandler | |
14 { | |
15 /** @var Error[] Collected errors */ | |
16 private $errors = []; | |
17 | |
18 public function handleError(Error $error) { | |
19 $this->errors[] = $error; | |
20 } | |
21 | |
22 /** | |
23 * Get collected errors. | |
24 * | |
25 * @return Error[] | |
26 */ | |
27 public function getErrors() { | |
28 return $this->errors; | |
29 } | |
30 | |
31 /** | |
32 * Check whether there are any errors. | |
33 * | |
34 * @return bool | |
35 */ | |
36 public function hasErrors() { | |
37 return !empty($this->errors); | |
38 } | |
39 | |
40 /** | |
41 * Reset/clear collected errors. | |
42 */ | |
43 public function clearErrors() { | |
44 $this->errors = []; | |
45 } | |
46 } |