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 |
||
| 24 | class ResetPasswordControl extends Control implements TranslatorAwareInterface |
||
| 25 | { |
||
| 26 | use TranslatorAwareTrait; |
||
| 27 | |||
| 28 | /** @var \SixtyEightPublishers\User\ForgotPassword\Entity\PasswordRequestInterface */ |
||
| 29 | private $passwordRequest; |
||
| 30 | |||
| 31 | /** @var \SixtyEightPublishers\User\Common\Logger\LoggerInterface */ |
||
| 32 | private $logger; |
||
| 33 | |||
| 34 | /** @var \SixtyEightPublishers\User\ForgotPassword\Mail\PasswordHasBeenResetEmailInterface */ |
||
| 35 | private $passwordHasBeenResetEmail; |
||
| 36 | |||
| 37 | /** @var \SixtyEightPublishers\User\ForgotPassword\PasswordRequest\PasswordRequestManagerInterface */ |
||
| 38 | private $passwordRequestManager; |
||
| 39 | |||
| 40 | /** @var \Nette\Security\User */ |
||
| 41 | private $user; |
||
| 42 | |||
| 43 | /** @var bool */ |
||
| 44 | private $autoLogin = FALSE; |
||
| 45 | |||
| 46 | /** @var callable[] */ |
||
| 47 | public $onSuccess = []; |
||
| 48 | |||
| 49 | /** @var callable[] */ |
||
| 50 | public $onError = []; |
||
| 51 | |||
| 52 | /** @var callable[] */ |
||
| 53 | public $onFormCreation = []; |
||
| 54 | |||
| 55 | /** |
||
| 56 | * @param \SixtyEightPublishers\User\ForgotPassword\Entity\PasswordRequestInterface $passwordRequest |
||
| 57 | * @param \SixtyEightPublishers\User\Common\Logger\LoggerInterface $logger |
||
| 58 | * @param \SixtyEightPublishers\User\ForgotPassword\Mail\PasswordHasBeenResetEmailInterface $passwordHasBeenResetEmail |
||
| 59 | * @param \SixtyEightPublishers\User\ForgotPassword\PasswordRequest\PasswordRequestManagerInterface $passwordRequestManager |
||
| 60 | * @param \Nette\Security\User $user |
||
| 61 | */ |
||
| 62 | public function __construct( |
||
| 75 | |||
| 76 | /** |
||
| 77 | * @param bool $autoLogin |
||
| 78 | * |
||
| 79 | * @return void |
||
| 80 | */ |
||
| 81 | public function setAutoLogin(bool $autoLogin): void |
||
| 85 | |||
| 86 | /** |
||
| 87 | * @return void |
||
| 88 | */ |
||
| 89 | public function render(): void |
||
| 94 | |||
| 95 | /** |
||
| 96 | * @return \Nette\Application\UI\Form |
||
| 97 | */ |
||
| 98 | View Code Duplication | protected function createComponentForm(): Form |
|
| 118 | |||
| 119 | /** |
||
| 120 | * @internal |
||
| 121 | * |
||
| 122 | * @param \Nette\Application\UI\Form $form |
||
| 123 | * |
||
| 124 | * @return void |
||
| 125 | * @throws \Nette\Security\AuthenticationException |
||
| 126 | */ |
||
| 127 | public function processForm(Form $form): void |
||
| 155 | } |
||
| 156 |
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.