Complex classes like AbstractUpdateAction often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use AbstractUpdateAction, and based on these observations, apply Extract Interface, too.
| 1 | <?php  | 
            ||
| 11 | class AbstractUpdateAction extends Param  | 
            ||
| 12 | { | 
            ||
| 13 | /**  | 
            ||
| 14 | * @var Document  | 
            ||
| 15 | */  | 
            ||
| 16 | protected $_upsert;  | 
            ||
| 17 | |||
| 18 | /**  | 
            ||
| 19 | * Sets the id of the document.  | 
            ||
| 20 | */  | 
            ||
| 21 | public function setId(?string $id = null): self  | 
            ||
| 25 | |||
| 26 | /**  | 
            ||
| 27 | * Returns document id.  | 
            ||
| 28 | *  | 
            ||
| 29 | * @return string|null Document id  | 
            ||
| 30 | */  | 
            ||
| 31 | public function getId(): ?string  | 
            ||
| 35 | |||
| 36 | public function hasId(): bool  | 
            ||
| 40 | |||
| 41 | /**  | 
            ||
| 42 | * Sets the document index name.  | 
            ||
| 43 | *  | 
            ||
| 44 | * @param Index|string $index Index name  | 
            ||
| 45 | */  | 
            ||
| 46 | public function setIndex($index): self  | 
            ||
| 54 | |||
| 55 | /**  | 
            ||
| 56 | * Get the document index name.  | 
            ||
| 57 | *  | 
            ||
| 58 | * @throws \Elastica\Exception\InvalidException  | 
            ||
| 59 | *  | 
            ||
| 60 | * @return string Index name  | 
            ||
| 61 | */  | 
            ||
| 62 | public function getIndex(): string  | 
            ||
| 66 | |||
| 67 | /**  | 
            ||
| 68 | * Sets the sequence number of a document for use with optimistic concurrency control.  | 
            ||
| 69 | *  | 
            ||
| 70 | * @param int $number Sequence Number  | 
            ||
| 71 | *  | 
            ||
| 72 | * @return $this  | 
            ||
| 73 | *  | 
            ||
| 74 | * @see https://www.elastic.co/guide/en/elasticsearch/reference/6.8/optimistic-concurrency-control.html  | 
            ||
| 75 | */  | 
            ||
| 76 | public function setSequenceNumber(int $number): self  | 
            ||
| 80 | |||
| 81 | /**  | 
            ||
| 82 | * Returns document version.  | 
            ||
| 83 | *  | 
            ||
| 84 | * @return int Document version  | 
            ||
| 85 | */  | 
            ||
| 86 | public function getSequenceNumber(): int  | 
            ||
| 90 | |||
| 91 | /**  | 
            ||
| 92 | * @return bool  | 
            ||
| 93 | */  | 
            ||
| 94 | public function hasSequenceNumber(): bool  | 
            ||
| 98 | |||
| 99 | /**  | 
            ||
| 100 | * Sets the primary term of a document for use with optimistic concurrency control.  | 
            ||
| 101 | *  | 
            ||
| 102 | * @param int $term Primary Term  | 
            ||
| 103 | *  | 
            ||
| 104 | * @return $this  | 
            ||
| 105 | *  | 
            ||
| 106 | * @see https://www.elastic.co/guide/en/elasticsearch/reference/6.8/optimistic-concurrency-control.html  | 
            ||
| 107 | */  | 
            ||
| 108 | public function setPrimaryTerm(int $term): self  | 
            ||
| 112 | |||
| 113 | /**  | 
            ||
| 114 | * Returns document version.  | 
            ||
| 115 | *  | 
            ||
| 116 | * @return int Document version  | 
            ||
| 117 | */  | 
            ||
| 118 | public function getPrimaryTerm(): int  | 
            ||
| 122 | |||
| 123 | /**  | 
            ||
| 124 | * @return bool  | 
            ||
| 125 | */  | 
            ||
| 126 | public function hasPrimaryTerm(): bool  | 
            ||
| 130 | |||
| 131 | /**  | 
            ||
| 132 | * Sets the version of a document.  | 
            ||
| 133 | *  | 
            ||
| 134 | * @param int $version Document version  | 
            ||
| 135 | *  | 
            ||
| 136 | * @return $this  | 
            ||
| 137 | *  | 
            ||
| 138 | * @see https://www.elastic.co/blog/versioning  | 
            ||
| 139 | */  | 
            ||
| 140 | public function setVersion(int $version): self  | 
            ||
| 144 | |||
| 145 | /**  | 
            ||
| 146 | * Returns document version.  | 
            ||
| 147 | *  | 
            ||
| 148 | * @return int Document version  | 
            ||
| 149 | */  | 
            ||
| 150 | public function getVersion(): int  | 
            ||
| 154 | |||
| 155 | /**  | 
            ||
| 156 | * @return bool  | 
            ||
| 157 | */  | 
            ||
| 158 | public function hasVersion(): bool  | 
            ||
| 162 | |||
| 163 | /**  | 
            ||
| 164 | * Set operation type.  | 
            ||
| 165 | *  | 
            ||
| 166 | * @param string $opType Only accept create  | 
            ||
| 167 | *  | 
            ||
| 168 | * @return $this  | 
            ||
| 169 | */  | 
            ||
| 170 | public function setOpType(string $opType): self  | 
            ||
| 174 | |||
| 175 | /**  | 
            ||
| 176 | * Get operation type.  | 
            ||
| 177 | *  | 
            ||
| 178 | * @return string  | 
            ||
| 179 | */  | 
            ||
| 180 | public function getOpType(): string  | 
            ||
| 184 | |||
| 185 | /**  | 
            ||
| 186 | * @return bool  | 
            ||
| 187 | */  | 
            ||
| 188 | public function hasOpType(): bool  | 
            ||
| 192 | |||
| 193 | /**  | 
            ||
| 194 | * Set routing query param.  | 
            ||
| 195 | *  | 
            ||
| 196 | * @param string $value routing  | 
            ||
| 197 | *  | 
            ||
| 198 | * @return $this  | 
            ||
| 199 | */  | 
            ||
| 200 | public function setRouting(string $value): self  | 
            ||
| 204 | |||
| 205 | /**  | 
            ||
| 206 | * Get routing parameter.  | 
            ||
| 207 | *  | 
            ||
| 208 | * @return string  | 
            ||
| 209 | */  | 
            ||
| 210 | public function getRouting(): string  | 
            ||
| 214 | |||
| 215 | /**  | 
            ||
| 216 | * @return bool  | 
            ||
| 217 | */  | 
            ||
| 218 | public function hasRouting(): bool  | 
            ||
| 222 | |||
| 223 | /**  | 
            ||
| 224 | * @param array|string $fields  | 
            ||
| 225 | *  | 
            ||
| 226 | * @return $this  | 
            ||
| 227 | */  | 
            ||
| 228 | public function setFields($fields): self  | 
            ||
| 236 | |||
| 237 | /**  | 
            ||
| 238 | * @return $this  | 
            ||
| 239 | */  | 
            ||
| 240 | public function setFieldsSource(): self  | 
            ||
| 244 | |||
| 245 | /**  | 
            ||
| 246 | * @return string  | 
            ||
| 247 | */  | 
            ||
| 248 | public function getFields(): string  | 
            ||
| 252 | |||
| 253 | /**  | 
            ||
| 254 | * @return bool  | 
            ||
| 255 | */  | 
            ||
| 256 | public function hasFields(): bool  | 
            ||
| 260 | |||
| 261 | /**  | 
            ||
| 262 | * @param int $num  | 
            ||
| 263 | *  | 
            ||
| 264 | * @return $this  | 
            ||
| 265 | */  | 
            ||
| 266 | public function setRetryOnConflict(int $num): self  | 
            ||
| 270 | |||
| 271 | /**  | 
            ||
| 272 | * @return int  | 
            ||
| 273 | */  | 
            ||
| 274 | public function getRetryOnConflict(): int  | 
            ||
| 278 | |||
| 279 | /**  | 
            ||
| 280 | * @return bool  | 
            ||
| 281 | */  | 
            ||
| 282 | public function hasRetryOnConflict(): bool  | 
            ||
| 286 | |||
| 287 | /**  | 
            ||
| 288 | * @param bool|string $refresh  | 
            ||
| 289 | *  | 
            ||
| 290 | * @return $this  | 
            ||
| 291 | */  | 
            ||
| 292 | public function setRefresh($refresh = true)  | 
            ||
| 300 | |||
| 301 | /**  | 
            ||
| 302 | * @return bool|string  | 
            ||
| 303 | */  | 
            ||
| 304 | public function getRefresh()  | 
            ||
| 312 | |||
| 313 | /**  | 
            ||
| 314 | * @return bool  | 
            ||
| 315 | */  | 
            ||
| 316 | public function hasRefresh(): bool  | 
            ||
| 320 | |||
| 321 | /**  | 
            ||
| 322 | * @param string $timeout  | 
            ||
| 323 | *  | 
            ||
| 324 | * @return $this  | 
            ||
| 325 | */  | 
            ||
| 326 | public function setTimeout(string $timeout): self  | 
            ||
| 330 | |||
| 331 | /**  | 
            ||
| 332 | * @return string  | 
            ||
| 333 | */  | 
            ||
| 334 | public function getTimeout(): string  | 
            ||
| 338 | |||
| 339 | /**  | 
            ||
| 340 | * @return bool  | 
            ||
| 341 | */  | 
            ||
| 342 | public function hasTimeout(): bool  | 
            ||
| 346 | |||
| 347 | /**  | 
            ||
| 348 | * @param string $timeout  | 
            ||
| 349 | *  | 
            ||
| 350 | * @return $this  | 
            ||
| 351 | */  | 
            ||
| 352 | public function setConsistency(string $timeout): self  | 
            ||
| 356 | |||
| 357 | /**  | 
            ||
| 358 | * @return string  | 
            ||
| 359 | */  | 
            ||
| 360 | public function getConsistency(): string  | 
            ||
| 364 | |||
| 365 | /**  | 
            ||
| 366 | * @return bool  | 
            ||
| 367 | */  | 
            ||
| 368 | public function hasConsistency(): bool  | 
            ||
| 372 | |||
| 373 | /**  | 
            ||
| 374 | * @param string $timeout  | 
            ||
| 375 | *  | 
            ||
| 376 | * @return $this  | 
            ||
| 377 | */  | 
            ||
| 378 | public function setReplication(string $timeout): self  | 
            ||
| 382 | |||
| 383 | /**  | 
            ||
| 384 | * @return string  | 
            ||
| 385 | */  | 
            ||
| 386 | public function getReplication(): string  | 
            ||
| 390 | |||
| 391 | /**  | 
            ||
| 392 | * @return bool  | 
            ||
| 393 | */  | 
            ||
| 394 | public function hasReplication(): bool  | 
            ||
| 398 | |||
| 399 | /**  | 
            ||
| 400 | * @param array|Document $data  | 
            ||
| 401 | *  | 
            ||
| 402 | * @return $this  | 
            ||
| 403 | */  | 
            ||
| 404 | public function setUpsert($data): self  | 
            ||
| 411 | |||
| 412 | /**  | 
            ||
| 413 | * @return Document  | 
            ||
| 414 | */  | 
            ||
| 415 | public function getUpsert(): Document  | 
            ||
| 419 | |||
| 420 | /**  | 
            ||
| 421 | * @return bool  | 
            ||
| 422 | */  | 
            ||
| 423 | public function hasUpsert(): bool  | 
            ||
| 427 | |||
| 428 | /**  | 
            ||
| 429 | * @param array $fields if empty array all options will be returned  | 
            ||
| 430 | *  | 
            ||
| 431 | * @return array  | 
            ||
| 432 | */  | 
            ||
| 433 | public function getOptions(array $fields = []): array  | 
            ||
| 441 | }  | 
            ||
| 442 | 
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..