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 |
||
| 23 | class ServerRenewProduct extends AbstractServerProduct |
||
| 24 | { |
||
| 25 | /** {@inheritdoc} */ |
||
| 26 | protected $_purchaseModel = 'hipanel\modules\server\cart\ServerRenewPurchase'; |
||
| 27 | |||
| 28 | /** {@inheritdoc} */ |
||
| 29 | protected $_calculationModel = RenewCalculation::class; |
||
| 30 | |||
| 31 | /** {@inheritdoc} */ |
||
| 32 | public static function primaryKey() |
||
| 36 | |||
| 37 | /** {@inheritdoc} */ |
||
| 38 | public function load($data, $formName = null) |
||
| 46 | |||
| 47 | /** {@inheritdoc} */ |
||
| 48 | private function ensureRelatedData() |
||
| 54 | |||
| 55 | /** {@inheritdoc} */ |
||
| 56 | public function getId() |
||
| 60 | |||
| 61 | /** {@inheritdoc} */ |
||
| 62 | public function getCalculationModel($options = []) |
||
| 71 | |||
| 72 | /** {@inheritdoc} */ |
||
| 73 | View Code Duplication | public function getQuantityOptions() |
|
| 87 | |||
| 88 | /** {@inheritdoc} */ |
||
| 89 | public function getPurchaseModel($options = []) |
||
| 94 | |||
| 95 | /** {@inheritdoc} */ |
||
| 96 | public function rules() |
||
| 103 | } |
||
| 104 |
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.