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 |
||
| 22 | class ServerRenewProduct extends AbstractServerProduct |
||
| 23 | { |
||
| 24 | /** {@inheritdoc} */ |
||
| 25 | protected $_purchaseModel = 'hipanel\modules\server\cart\ServerRenewPurchase'; |
||
| 26 | |||
| 27 | /** {@inheritdoc} */ |
||
| 28 | protected $_calculationModel = RenewCalculation::class; |
||
| 29 | |||
| 30 | /** {@inheritdoc} */ |
||
| 31 | public static function primaryKey() |
||
| 35 | |||
| 36 | /** {@inheritdoc} */ |
||
| 37 | public function load($data, $formName = null) |
||
| 45 | |||
| 46 | /** {@inheritdoc} */ |
||
| 47 | private function ensureRelatedData() |
||
| 53 | |||
| 54 | /** {@inheritdoc} */ |
||
| 55 | public function getId() |
||
| 59 | |||
| 60 | /** {@inheritdoc} */ |
||
| 61 | public function getCalculationModel($options = []) |
||
| 70 | |||
| 71 | /** {@inheritdoc} */ |
||
| 72 | View Code Duplication | public function getQuantityOptions() |
|
| 86 | |||
| 87 | /** {@inheritdoc} */ |
||
| 88 | public function getPurchaseModel($options = []) |
||
| 93 | |||
| 94 | /** {@inheritdoc} */ |
||
| 95 | public function rules() |
||
| 102 | |||
| 103 | public function renderDescription() |
||
| 107 | } |
||
| 108 |
Since your code implements the magic getter
_get, this function will be called for any read access on an undefined variable. You can add the@propertyannotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read 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.