1 | <?php |
||
28 | abstract class AbstractHelper |
||
29 | { |
||
30 | /** |
||
31 | * @var XoopsModule |
||
32 | */ |
||
33 | protected $module; |
||
34 | |||
35 | /** |
||
36 | * @var bool true if debug is enabled |
||
37 | */ |
||
38 | protected $debug; |
||
39 | |||
40 | /** |
||
41 | * Instantiate a XoopsModule object for the helper to use. |
||
42 | * The module is determined as follows: |
||
43 | * - if null is passed, use the current module |
||
44 | * - if a string is passed, use as dirname to load |
||
45 | * |
||
46 | * @param string|null $dirname dirname |
||
47 | */ |
||
48 | public function __construct($dirname = null) |
||
72 | |||
73 | /** |
||
74 | * init() is called once/if __construct has a module object. |
||
75 | * $this->module will have a module object that any further |
||
76 | * initialization can use. |
||
77 | * |
||
78 | * @return void |
||
79 | */ |
||
80 | abstract public function init(); |
||
81 | |||
82 | /** |
||
83 | * Set debug option on or off |
||
84 | * |
||
85 | * @param bool $bool true to turn on debug logging, false for off |
||
86 | * |
||
87 | * @return void |
||
88 | */ |
||
89 | 1 | public function setDebug($bool = true) |
|
93 | |||
94 | /** |
||
95 | * Add a message to the module log |
||
96 | * |
||
97 | * @param string $log log message |
||
98 | * |
||
99 | * @return void |
||
100 | */ |
||
101 | 1 | public function addLog($log) |
|
107 | } |
||
108 |
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.
For example, imagine you have a variable
$accountId
that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to theid
property of an instance of theAccount
class. This class holds a proper account, so the id value must no longer be false.Either this assignment is in error or a type check should be added for that assignment.