1 | <?php |
||
10 | abstract class AbstractResult implements ResultInterface |
||
11 | { |
||
12 | const STATUS_OK = 0; |
||
13 | |||
14 | /** |
||
15 | * @var int |
||
16 | */ |
||
17 | protected $status; |
||
18 | |||
19 | /** |
||
20 | * @var CheckException|null |
||
21 | */ |
||
22 | protected $error; |
||
23 | |||
24 | /** |
||
25 | * CheckResult constructor. |
||
26 | * |
||
27 | * @param int $status |
||
28 | * @param CheckException $error |
||
29 | */ |
||
30 | public function __construct($status, CheckException $error = null) |
||
35 | |||
36 | /** |
||
37 | * @return int |
||
38 | */ |
||
39 | public function getStatus() |
||
43 | |||
44 | /** |
||
45 | * @return CheckException|null |
||
46 | */ |
||
47 | public function getError() |
||
51 | |||
52 | /** |
||
53 | * @return bool |
||
54 | */ |
||
55 | public function isOk() |
||
59 | |||
60 | /** |
||
61 | * Get message related to the result. |
||
62 | * |
||
63 | * @return string |
||
64 | */ |
||
65 | public function getMessage() |
||
73 | |||
74 | /** |
||
75 | * Get detailed info on the test result (if available). |
||
76 | * |
||
77 | * @return mixed|null |
||
78 | */ |
||
79 | public function getData() |
||
83 | |||
84 | /** |
||
85 | * @param int $status |
||
86 | */ |
||
87 | protected function setStatus($status) |
||
91 | |||
92 | /** |
||
93 | * @param CheckException|null $error |
||
94 | */ |
||
95 | protected function setError(CheckException $error = null) |
||
99 | } |
||
100 |
PHP Analyzer performs a side-effects analysis of your code. A side-effect is basically anything that might be visible after the scope of the method is left.
Let’s take a look at an example:
If we look at the
getEmail()
method, we can see that it has no side-effect. Whether you call this method or not, no future calls to other methods are affected by this. As such code as the following is useless:On the hand, if we look at the
setEmail()
, this method _has_ side-effects. In the following case, we could not remove the method call: