1 | <?php |
||
11 | abstract class AbstractWidget extends BaseAbstractWidget |
||
12 | { |
||
13 | const ID_PREFIX = 'widget-'; |
||
14 | |||
15 | /** |
||
16 | * @var string |
||
17 | */ |
||
18 | private $id; |
||
19 | |||
20 | /** |
||
21 | * Constructor |
||
22 | * Store the configuration & initialise the widget |
||
23 | * |
||
24 | * @param array $config |
||
25 | */ |
||
26 | public function __construct($config = []) |
||
33 | |||
34 | /** |
||
35 | * Custom initilisation for the widget |
||
36 | * |
||
37 | * @return boolean |
||
38 | */ |
||
39 | protected function init() |
||
43 | |||
44 | /** |
||
45 | * Retrieve the configuration value from the widget, based |
||
46 | * on the supplied key |
||
47 | * |
||
48 | * @param string $key |
||
49 | * @param mixed $default |
||
50 | * @return mixed |
||
51 | */ |
||
52 | public function cfg($key, $default = null) |
||
62 | |||
63 | /** |
||
64 | * Add a configuration into the widget |
||
65 | * |
||
66 | * @param string $key |
||
67 | * @param mixed $value |
||
68 | * @return nil|null |
||
69 | */ |
||
70 | public function addCfg($key, $value) |
||
78 | |||
79 | /** |
||
80 | * Retrieve the widget id |
||
81 | * |
||
82 | * @param boolean $autoGenerate automatically generate the id if none is |
||
83 | * already set |
||
84 | * @return string |
||
85 | */ |
||
86 | public function getId($autoGenerate = true) |
||
93 | |||
94 | /** |
||
95 | * Set the widget identifier |
||
96 | * |
||
97 | * @param string $id |
||
98 | */ |
||
99 | public function setId($id) |
||
103 | |||
104 | /** |
||
105 | * Determine if the public property exists, and is public |
||
106 | * |
||
107 | * @param string $propertyName |
||
108 | * @return boolean |
||
109 | */ |
||
110 | private function isConfigProperty($propertyName) |
||
121 | } |
||
122 |
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: