1 | <?php |
||
13 | trait ErrorHandler |
||
14 | { |
||
15 | /** |
||
16 | * @var mixed[] |
||
17 | */ |
||
18 | private $errors; |
||
19 | |||
20 | /** |
||
21 | * Assert that the requested error was generated. |
||
22 | * |
||
23 | * @param string $errstr |
||
24 | * @param int $errno |
||
25 | */ |
||
26 | 8 | public function assertError(string $errstr, int $errno) |
|
37 | |||
38 | /** |
||
39 | * Assert that no errors were generated. |
||
40 | */ |
||
41 | 1 | public function assertNoErrors() |
|
45 | |||
46 | /** |
||
47 | * Activate PHPUnit error handler. |
||
48 | * |
||
49 | * @before |
||
50 | */ |
||
51 | 9 | protected function setUpErrorHandler() |
|
67 | } |
||
68 |
This check looks for methods that are used by a trait but not required by it.
To illustrate, let’s look at the following code example
The trait
Idable
provides a methodequalsId
that in turn relies on the methodgetId()
. If this method does not exist on a class mixing in this trait, the method will fail.Adding the
getId()
as an abstract method to the trait will make sure it is available.