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 |
||
| 19 | class MultipleIdentifierMapper extends IdentifierMapper |
||
| 20 | { |
||
| 21 | /** |
||
| 22 | * Check if field can be mapped. |
||
| 23 | * |
||
| 24 | * @param \eZ\Publish\SPI\Search\Field $field |
||
| 25 | * |
||
| 26 | * @return bool |
||
| 27 | */ |
||
| 28 | public function canMap(Field $field) |
||
| 32 | |||
| 33 | /** |
||
| 34 | * Map field value to a proper Elasticsearch representation. |
||
| 35 | * |
||
| 36 | * @param \eZ\Publish\SPI\Search\Field $field |
||
| 37 | * |
||
| 38 | * @return mixed |
||
| 39 | */ |
||
| 40 | View Code Duplication | public function map(Field $field) |
|
| 50 | } |
||
| 51 |
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.