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 | class Menuitem extends Entitizer\Utils\Handler { |
||
15 | |||
16 | use Entitizer\Common\Menuitem; |
||
17 | |||
18 | protected $_title = 'TITLE_CONTENT_MENUITEMS_EDIT'; |
||
19 | |||
20 | # Handler configuration |
||
21 | |||
22 | protected static $naming = 'text', $naming_new = ''; |
||
23 | |||
24 | protected static $view = 'Blocks/Entitizer/Menuitems/Main'; |
||
25 | |||
26 | protected static $form_class = 'Modules\Entitizer\Form\Menuitem'; |
||
27 | |||
28 | protected static $controller_class = 'Modules\Entitizer\Controller\Menuitem'; |
||
29 | |||
30 | protected static $message_success_save = 'MENUITEM_SUCCESS_SAVE'; |
||
31 | |||
32 | protected static $message_error_move = 'MENUITEM_ERROR_MOVE'; |
||
33 | |||
34 | protected static $message_error_remove = 'MENUITEM_ERROR_REMOVE'; |
||
35 | |||
36 | protected static $link = '/admin/content/menuitems'; |
||
37 | |||
38 | /** |
||
39 | * Add parent's additional data |
||
40 | */ |
||
41 | |||
42 | protected function processEntityParent(Template\Block $parent) { |
||
48 | |||
49 | /** |
||
50 | * Add additional data for a specific entity |
||
51 | */ |
||
52 | |||
53 | protected function processEntity(Template\Block $contents) {} |
||
54 | } |
||
55 | } |
||
56 |
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.