Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
| 1 | <?php |
||
| 14 | abstract class Addons extends Extend\Utils\Handler { |
||
| 15 | |||
| 16 | /** |
||
| 17 | * Process the item block |
||
| 18 | */ |
||
| 19 | |||
| 20 | protected function processItem(Template\Block $item, array $data) { |
||
| 30 | |||
| 31 | /** |
||
| 32 | * Process the contents block |
||
| 33 | */ |
||
| 34 | |||
| 35 | protected function processContents(Template\Block $contents) {} |
||
| 36 | |||
| 37 | /** |
||
| 38 | * Handle the ajax request |
||
| 39 | */ |
||
| 40 | |||
| 41 | protected function handleAjax() : Ajax\Response { |
||
| 64 | |||
| 65 | /** |
||
| 66 | * Handle the request |
||
| 67 | * |
||
| 68 | * @return Template\Block|Ajax\Response : a block object if the ajax param was set to false, otherwise an ajax response |
||
| 69 | */ |
||
| 70 | |||
| 71 | View Code Duplication | public function handle(bool $ajax = false) { |
|
| 81 | } |
||
| 82 | } |
||
| 83 |
Since your code implements the magic setter
_set, this function will be called for any write access on an undefined variable. You can add the@propertyannotation to your class or interface to document the existence of this variable.Since the property has write access only, you can use the @property-write annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.