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 Basic extends Extend\Utils\Handler { |
||
15 | |||
16 | /** |
||
17 | * Process the item block |
||
18 | */ |
||
19 | |||
20 | protected function processItem(Template\Block $item, array $data) { |
||
24 | |||
25 | /** |
||
26 | * Process the contents block |
||
27 | */ |
||
28 | |||
29 | protected function processContents(Template\Block $contents) { |
||
33 | |||
34 | /** |
||
35 | * Handle the ajax request |
||
36 | */ |
||
37 | |||
38 | protected function handleAjax() : Ajax\Response { |
||
59 | |||
60 | /** |
||
61 | * Handle the request |
||
62 | * |
||
63 | * @return Template\Block|Ajax\Response : a block object if the ajax param was set to false, otherwise an ajax response |
||
64 | */ |
||
65 | |||
66 | View Code Duplication | public function handle(bool $ajax = false) { |
|
76 | } |
||
77 | } |
||
78 |
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@property
annotation 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.