1 | <?php |
||
22 | class Check extends Abstraction |
||
23 | { |
||
24 | /** |
||
25 | * Failure state of all executed Checks. |
||
26 | * |
||
27 | * @var boolean |
||
28 | */ |
||
29 | private $failure = false; |
||
30 | |||
31 | /** |
||
32 | * Executes a backup check. |
||
33 | * |
||
34 | * @param \phpbu\App\Backup\Check $check |
||
35 | * @param \phpbu\App\Configuration\Backup\Check $config |
||
36 | * @param \phpbu\App\Backup\Target $target |
||
37 | * @param \phpbu\App\Backup\Collector $collector |
||
38 | * @param \phpbu\App\Result $result |
||
39 | */ |
||
40 | 3 | public function run(CheckExe $check, CheckConfig $config, Target $target, Collector $collector, Result $result) |
|
41 | { |
||
42 | try { |
||
43 | 3 | $result->checkStart($config); |
|
44 | |||
45 | 3 | if ($this->check($check, $config->value, $target, $collector, $result)) { |
|
|
|||
46 | 1 | $result->checkEnd($config); |
|
47 | 1 | } else { |
|
48 | 1 | $this->failure = true; |
|
49 | 1 | $result->checkFailed($config); |
|
50 | } |
||
51 | 3 | } catch (Exception $e) { |
|
52 | 1 | $this->failure = true; |
|
53 | 1 | $result->addError($e); |
|
54 | 1 | $result->checkFailed($config); |
|
55 | } |
||
56 | 3 | } |
|
57 | |||
58 | /** |
||
59 | * Return true if the last check did fail. |
||
60 | * |
||
61 | * @return boolean |
||
62 | */ |
||
63 | 3 | public function hasFailed() |
|
67 | |||
68 | /** |
||
69 | * Executes the actual check. |
||
70 | * |
||
71 | * @param \phpbu\App\Backup\Check $check |
||
72 | * @param string $value |
||
73 | * @param \phpbu\App\Backup\Target $target |
||
74 | * @param \phpbu\App\Backup\Collector $collector |
||
75 | * @return bool |
||
76 | */ |
||
77 | protected function check(CheckExe $check, $value, Target $target, Collector $collector) |
||
81 | |||
82 | } |
||
83 |
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.
In this case you can add the
@ignore
PhpDoc annotation to the duplicate definition and it will be ignored.