| 1 | <?php |
||
| 10 | abstract class AbstractWidget extends BaseAbstractWidget |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * Constructor |
||
| 14 | * Store the configuration & initialise the widget |
||
| 15 | * |
||
| 16 | * @param array $config |
||
| 17 | */ |
||
| 18 | public function __construct($config = []) |
||
| 25 | |||
| 26 | /** |
||
| 27 | * Custom initilisation for the widget |
||
| 28 | * |
||
| 29 | * @return boolean |
||
| 30 | */ |
||
| 31 | protected function init() |
||
| 35 | |||
| 36 | /** |
||
| 37 | * Retrieve the configuration value from the widget, based |
||
| 38 | * on the supplied key |
||
| 39 | * |
||
| 40 | * @param string $key |
||
| 41 | * @param mixed $default |
||
| 42 | * @return mixed |
||
| 43 | */ |
||
| 44 | public function cfg($key, $default = null) |
||
| 54 | |||
| 55 | /** |
||
| 56 | * Add a configuration into the widget |
||
| 57 | * |
||
| 58 | * @param string $key |
||
| 59 | * @param mixed $value |
||
| 60 | * @return nil |
||
| 61 | */ |
||
| 62 | public function addCfg($key, $value) |
||
| 70 | |||
| 71 | /** |
||
| 72 | * Determine if the public property exists, and is public |
||
| 73 | * |
||
| 74 | * @param string $propertyName |
||
| 75 | * @return boolean |
||
| 76 | */ |
||
| 77 | private function isConfigProperty($propertyName) |
||
| 88 | } |
||
| 89 |
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: