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 Content extends APIContent |
||
| 25 | { |
||
| 26 | /** |
||
| 27 | * @var mixed[][] An array of array of field values like[$fieldDefIdentifier][$languageCode] |
||
| 28 | */ |
||
| 29 | protected $fields; |
||
| 30 | |||
| 31 | /** |
||
| 32 | * @var \eZ\Publish\API\Repository\Values\Content\VersionInfo |
||
| 33 | */ |
||
| 34 | protected $versionInfo; |
||
| 35 | |||
| 36 | /** |
||
| 37 | * @var \eZ\Publish\API\Repository\Values\Content\Field[] An array of {@link Field} |
||
| 38 | */ |
||
| 39 | private $internalFields = array(); |
||
| 40 | |||
| 41 | /** |
||
| 42 | * The first matched field language among user provided prioritized languages. |
||
| 43 | * |
||
| 44 | * The first matched language among user provided prioritized languages on object retrieval, or null if none |
||
| 45 | * provided (all languages) or on main fallback. |
||
| 46 | * |
||
| 47 | * @internal |
||
| 48 | * @var string|null |
||
| 49 | */ |
||
| 50 | protected $prioritizedFieldLanguageCode; |
||
| 51 | |||
| 52 | View Code Duplication | public function __construct(array $data = array()) |
|
| 61 | |||
| 62 | /** |
||
| 63 | * {@inheritdoc} |
||
| 64 | */ |
||
| 65 | public function getVersionInfo() |
||
| 69 | |||
| 70 | /** |
||
| 71 | * {@inheritdoc} |
||
| 72 | */ |
||
| 73 | public function getName($languageCode = null) |
||
| 77 | |||
| 78 | /** |
||
| 79 | * {@inheritdoc} |
||
| 80 | */ |
||
| 81 | View Code Duplication | public function getFieldValue($fieldDefIdentifier, $languageCode = null) |
|
| 93 | |||
| 94 | /** |
||
| 95 | * {@inheritdoc} |
||
| 96 | */ |
||
| 97 | public function getFields() |
||
| 101 | |||
| 102 | /** |
||
| 103 | * {@inheritdoc} |
||
| 104 | */ |
||
| 105 | View Code Duplication | public function getFieldsByLanguage($languageCode = null) |
|
| 122 | |||
| 123 | /** |
||
| 124 | * {@inheritdoc} |
||
| 125 | */ |
||
| 126 | public function getField($fieldDefIdentifier, $languageCode = null) |
||
| 141 | |||
| 142 | /** |
||
| 143 | * {@inheritdoc} |
||
| 144 | */ |
||
| 145 | protected function getProperties($dynamicProperties = array('id', 'contentInfo')) |
||
| 149 | |||
| 150 | /** |
||
| 151 | * {@inheritdoc} |
||
| 152 | */ |
||
| 153 | public function __get($property) |
||
| 165 | |||
| 166 | /** |
||
| 167 | * {@inheritdoc} |
||
| 168 | */ |
||
| 169 | public function __isset($property) |
||
| 181 | } |
||
| 182 |
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.