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 Action { |
||
| 15 | |||
| 16 | protected $code = null, $user = null, $form = null; |
||
| 17 | |||
| 18 | # Action configuration interface |
||
| 19 | |||
| 20 | protected static $view = '', $form_class = '', $controller_class = ''; |
||
| 21 | |||
| 22 | protected static $redirect = '', $messages = []; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * Get the contents block |
||
| 26 | */ |
||
| 27 | |||
| 28 | private function getContents() : Template\Block { |
||
| 44 | |||
| 45 | /** |
||
| 46 | * Handle the request |
||
| 47 | */ |
||
| 48 | |||
| 49 | public function handle() : Template\Block { |
||
| 73 | } |
||
| 74 | } |
||
| 75 |
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.