Complex classes like KeyInfoType 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 KeyInfoType, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 11 | class KeyInfoType |
||
| 12 | { |
||
| 13 | |||
| 14 | /** |
||
| 15 | * @property string $id |
||
| 16 | */ |
||
| 17 | private $id = null; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * @property string[] $keyName |
||
| 21 | */ |
||
| 22 | private $keyName = 'array()'; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * @property |
||
| 26 | * \GoetasWebservices\SoapServices\SoapClient\WssWsSecurity\XmlSign\KeyValue[] |
||
| 27 | * $keyValue |
||
| 28 | */ |
||
| 29 | private $keyValue = 'array()'; |
||
| 30 | |||
| 31 | /** |
||
| 32 | * @property |
||
| 33 | * \GoetasWebservices\SoapServices\SoapClient\WssWsSecurity\XmlSign\RetrievalMethod[] |
||
| 34 | * $retrievalMethod |
||
| 35 | */ |
||
| 36 | private $retrievalMethod = 'array()'; |
||
| 37 | |||
| 38 | /** |
||
| 39 | * @property |
||
| 40 | * \GoetasWebservices\SoapServices\SoapClient\WssWsSecurity\XmlSign\X509Data[] |
||
| 41 | * $x509Data |
||
| 42 | */ |
||
| 43 | private $x509Data = 'array()'; |
||
| 44 | |||
| 45 | /** |
||
| 46 | * @property |
||
| 47 | * \GoetasWebservices\SoapServices\SoapClient\WssWsSecurity\XmlSign\PGPData[] |
||
| 48 | * $pGPData |
||
| 49 | */ |
||
| 50 | private $pGPData = 'array()'; |
||
| 51 | |||
| 52 | /** |
||
| 53 | * @property mixed[] $sPKIData |
||
| 54 | */ |
||
| 55 | private $sPKIData = null; |
||
| 56 | |||
| 57 | /** |
||
| 58 | * @property string[] $mgmtData |
||
| 59 | */ |
||
| 60 | private $mgmtData = 'array()'; |
||
| 61 | |||
| 62 | /** |
||
| 63 | * @property mixed[] $anyElement |
||
| 64 | */ |
||
| 65 | private $anyElement = array( |
||
| 66 | |||
| 67 | ); |
||
| 68 | |||
| 69 | /** |
||
| 70 | * Gets as id |
||
| 71 | * |
||
| 72 | * @return string |
||
| 73 | */ |
||
| 74 | public function getId() |
||
| 78 | |||
| 79 | /** |
||
| 80 | * Sets a new id |
||
| 81 | * |
||
| 82 | * @param string $id |
||
| 83 | * @return self |
||
| 84 | */ |
||
| 85 | public function setId($id) |
||
| 90 | |||
| 91 | /** |
||
| 92 | * Adds as keyName |
||
| 93 | * |
||
| 94 | * @return self |
||
| 95 | * @param string $keyName |
||
| 96 | */ |
||
| 97 | public function addToKeyName($keyName) |
||
| 102 | |||
| 103 | /** |
||
| 104 | * isset keyName |
||
| 105 | * |
||
| 106 | * @param scalar $index |
||
| 107 | * @return boolean |
||
| 108 | */ |
||
| 109 | public function issetKeyName($index) |
||
| 113 | |||
| 114 | /** |
||
| 115 | * unset keyName |
||
| 116 | * |
||
| 117 | * @param scalar $index |
||
| 118 | * @return void |
||
| 119 | */ |
||
| 120 | public function unsetKeyName($index) |
||
| 124 | |||
| 125 | /** |
||
| 126 | * Gets as keyName |
||
| 127 | * |
||
| 128 | * @return string[] |
||
| 129 | */ |
||
| 130 | public function getKeyName() |
||
| 134 | |||
| 135 | /** |
||
| 136 | * Sets a new keyName |
||
| 137 | * |
||
| 138 | * @param string $keyName |
||
| 139 | * @return self |
||
| 140 | */ |
||
| 141 | public function setKeyName(array $keyName) |
||
| 146 | |||
| 147 | /** |
||
| 148 | * Adds as keyValue |
||
| 149 | * |
||
| 150 | * @return self |
||
| 151 | * @param \GoetasWebservices\SoapServices\SoapClient\WssWsSecurity\XmlSign\KeyValue |
||
| 152 | * $keyValue |
||
| 153 | */ |
||
| 154 | public function addToKeyValue(\GoetasWebservices\SoapServices\SoapClient\WssWsSecurity\XmlSign\KeyValue $keyValue) |
||
| 159 | |||
| 160 | /** |
||
| 161 | * isset keyValue |
||
| 162 | * |
||
| 163 | * @param scalar $index |
||
| 164 | * @return boolean |
||
| 165 | */ |
||
| 166 | public function issetKeyValue($index) |
||
| 170 | |||
| 171 | /** |
||
| 172 | * unset keyValue |
||
| 173 | * |
||
| 174 | * @param scalar $index |
||
| 175 | * @return void |
||
| 176 | */ |
||
| 177 | public function unsetKeyValue($index) |
||
| 181 | |||
| 182 | /** |
||
| 183 | * Gets as keyValue |
||
| 184 | * |
||
| 185 | * @return |
||
| 186 | * \GoetasWebservices\SoapServices\SoapClient\WssWsSecurity\XmlSign\KeyValue[] |
||
| 187 | */ |
||
| 188 | public function getKeyValue() |
||
| 192 | |||
| 193 | /** |
||
| 194 | * Sets a new keyValue |
||
| 195 | * |
||
| 196 | * @param |
||
| 197 | * \GoetasWebservices\SoapServices\SoapClient\WssWsSecurity\XmlSign\KeyValue[] |
||
| 198 | * $keyValue |
||
| 199 | * @return self |
||
| 200 | */ |
||
| 201 | public function setKeyValue(array $keyValue) |
||
| 206 | |||
| 207 | /** |
||
| 208 | * Adds as retrievalMethod |
||
| 209 | * |
||
| 210 | * @return self |
||
| 211 | * @param |
||
| 212 | * \GoetasWebservices\SoapServices\SoapClient\WssWsSecurity\XmlSign\RetrievalMethod |
||
| 213 | * $retrievalMethod |
||
| 214 | */ |
||
| 215 | public function addToRetrievalMethod(\GoetasWebservices\SoapServices\SoapClient\WssWsSecurity\XmlSign\RetrievalMethod $retrievalMethod) |
||
| 220 | |||
| 221 | /** |
||
| 222 | * isset retrievalMethod |
||
| 223 | * |
||
| 224 | * @param scalar $index |
||
| 225 | * @return boolean |
||
| 226 | */ |
||
| 227 | public function issetRetrievalMethod($index) |
||
| 231 | |||
| 232 | /** |
||
| 233 | * unset retrievalMethod |
||
| 234 | * |
||
| 235 | * @param scalar $index |
||
| 236 | * @return void |
||
| 237 | */ |
||
| 238 | public function unsetRetrievalMethod($index) |
||
| 242 | |||
| 243 | /** |
||
| 244 | * Gets as retrievalMethod |
||
| 245 | * |
||
| 246 | * @return |
||
| 247 | * \GoetasWebservices\SoapServices\SoapClient\WssWsSecurity\XmlSign\RetrievalMethod[] |
||
| 248 | */ |
||
| 249 | public function getRetrievalMethod() |
||
| 253 | |||
| 254 | /** |
||
| 255 | * Sets a new retrievalMethod |
||
| 256 | * |
||
| 257 | * @param |
||
| 258 | * \GoetasWebservices\SoapServices\SoapClient\WssWsSecurity\XmlSign\RetrievalMethod[] |
||
| 259 | * $retrievalMethod |
||
| 260 | * @return self |
||
| 261 | */ |
||
| 262 | public function setRetrievalMethod(array $retrievalMethod) |
||
| 267 | |||
| 268 | /** |
||
| 269 | * Adds as x509Data |
||
| 270 | * |
||
| 271 | * @return self |
||
| 272 | * @param \GoetasWebservices\SoapServices\SoapClient\WssWsSecurity\XmlSign\X509Data |
||
| 273 | * $x509Data |
||
| 274 | */ |
||
| 275 | public function addToX509Data(\GoetasWebservices\SoapServices\SoapClient\WssWsSecurity\XmlSign\X509Data $x509Data) |
||
| 280 | |||
| 281 | /** |
||
| 282 | * isset x509Data |
||
| 283 | * |
||
| 284 | * @param scalar $index |
||
| 285 | * @return boolean |
||
| 286 | */ |
||
| 287 | public function issetX509Data($index) |
||
| 291 | |||
| 292 | /** |
||
| 293 | * unset x509Data |
||
| 294 | * |
||
| 295 | * @param scalar $index |
||
| 296 | * @return void |
||
| 297 | */ |
||
| 298 | public function unsetX509Data($index) |
||
| 302 | |||
| 303 | /** |
||
| 304 | * Gets as x509Data |
||
| 305 | * |
||
| 306 | * @return |
||
| 307 | * \GoetasWebservices\SoapServices\SoapClient\WssWsSecurity\XmlSign\X509Data[] |
||
| 308 | */ |
||
| 309 | public function getX509Data() |
||
| 313 | |||
| 314 | /** |
||
| 315 | * Sets a new x509Data |
||
| 316 | * |
||
| 317 | * @param |
||
| 318 | * \GoetasWebservices\SoapServices\SoapClient\WssWsSecurity\XmlSign\X509Data[] |
||
| 319 | * $x509Data |
||
| 320 | * @return self |
||
| 321 | */ |
||
| 322 | public function setX509Data(array $x509Data) |
||
| 327 | |||
| 328 | /** |
||
| 329 | * Adds as pGPData |
||
| 330 | * |
||
| 331 | * @return self |
||
| 332 | * @param \GoetasWebservices\SoapServices\SoapClient\WssWsSecurity\XmlSign\PGPData |
||
| 333 | * $pGPData |
||
| 334 | */ |
||
| 335 | public function addToPGPData(\GoetasWebservices\SoapServices\SoapClient\WssWsSecurity\XmlSign\PGPData $pGPData) |
||
| 340 | |||
| 341 | /** |
||
| 342 | * isset pGPData |
||
| 343 | * |
||
| 344 | * @param scalar $index |
||
| 345 | * @return boolean |
||
| 346 | */ |
||
| 347 | public function issetPGPData($index) |
||
| 351 | |||
| 352 | /** |
||
| 353 | * unset pGPData |
||
| 354 | * |
||
| 355 | * @param scalar $index |
||
| 356 | * @return void |
||
| 357 | */ |
||
| 358 | public function unsetPGPData($index) |
||
| 362 | |||
| 363 | /** |
||
| 364 | * Gets as pGPData |
||
| 365 | * |
||
| 366 | * @return |
||
| 367 | * \GoetasWebservices\SoapServices\SoapClient\WssWsSecurity\XmlSign\PGPData[] |
||
| 368 | */ |
||
| 369 | public function getPGPData() |
||
| 373 | |||
| 374 | /** |
||
| 375 | * Sets a new pGPData |
||
| 376 | * |
||
| 377 | * @param |
||
| 378 | * \GoetasWebservices\SoapServices\SoapClient\WssWsSecurity\XmlSign\PGPData[] |
||
| 379 | * $pGPData |
||
| 380 | * @return self |
||
| 381 | */ |
||
| 382 | public function setPGPData(array $pGPData) |
||
| 387 | |||
| 388 | /** |
||
| 389 | * Adds as sPKISexp |
||
| 390 | * |
||
| 391 | * @return self |
||
| 392 | * @param mixed $sPKISexp |
||
| 393 | */ |
||
| 394 | public function addToSPKIData($sPKISexp) |
||
| 399 | |||
| 400 | /** |
||
| 401 | * isset sPKIData |
||
| 402 | * |
||
| 403 | * @param scalar $index |
||
| 404 | * @return boolean |
||
| 405 | */ |
||
| 406 | public function issetSPKIData($index) |
||
| 410 | |||
| 411 | /** |
||
| 412 | * unset sPKIData |
||
| 413 | * |
||
| 414 | * @param scalar $index |
||
| 415 | * @return void |
||
| 416 | */ |
||
| 417 | public function unsetSPKIData($index) |
||
| 421 | |||
| 422 | /** |
||
| 423 | * Gets as sPKIData |
||
| 424 | * |
||
| 425 | * @return mixed[] |
||
| 426 | */ |
||
| 427 | public function getSPKIData() |
||
| 431 | |||
| 432 | /** |
||
| 433 | * Sets a new sPKIData |
||
| 434 | * |
||
| 435 | * @param mixed $sPKIData |
||
| 436 | * @return self |
||
| 437 | */ |
||
| 438 | public function setSPKIData(array $sPKIData) |
||
| 443 | |||
| 444 | /** |
||
| 445 | * Adds as mgmtData |
||
| 446 | * |
||
| 447 | * @return self |
||
| 448 | * @param string $mgmtData |
||
| 449 | */ |
||
| 450 | public function addToMgmtData($mgmtData) |
||
| 455 | |||
| 456 | /** |
||
| 457 | * isset mgmtData |
||
| 458 | * |
||
| 459 | * @param scalar $index |
||
| 460 | * @return boolean |
||
| 461 | */ |
||
| 462 | public function issetMgmtData($index) |
||
| 466 | |||
| 467 | /** |
||
| 468 | * unset mgmtData |
||
| 469 | * |
||
| 470 | * @param scalar $index |
||
| 471 | * @return void |
||
| 472 | */ |
||
| 473 | public function unsetMgmtData($index) |
||
| 477 | |||
| 478 | /** |
||
| 479 | * Gets as mgmtData |
||
| 480 | * |
||
| 481 | * @return string[] |
||
| 482 | */ |
||
| 483 | public function getMgmtData() |
||
| 487 | |||
| 488 | /** |
||
| 489 | * Sets a new mgmtData |
||
| 490 | * |
||
| 491 | * @param string $mgmtData |
||
| 492 | * @return self |
||
| 493 | */ |
||
| 494 | public function setMgmtData(array $mgmtData) |
||
| 499 | |||
| 500 | /** |
||
| 501 | * Adds as array |
||
| 502 | * |
||
| 503 | * @return self |
||
| 504 | * @param mixed $array |
||
| 505 | */ |
||
| 506 | public function addToAnyElement($array) |
||
| 511 | |||
| 512 | /** |
||
| 513 | * isset anyElement |
||
| 514 | * |
||
| 515 | * @param scalar $index |
||
| 516 | * @return boolean |
||
| 517 | */ |
||
| 518 | public function issetAnyElement($index) |
||
| 522 | |||
| 523 | /** |
||
| 524 | * unset anyElement |
||
| 525 | * |
||
| 526 | * @param scalar $index |
||
| 527 | * @return void |
||
| 528 | */ |
||
| 529 | public function unsetAnyElement($index) |
||
| 533 | |||
| 534 | /** |
||
| 535 | * Gets as anyElement |
||
| 536 | * |
||
| 537 | * @return mixed[] |
||
| 538 | */ |
||
| 539 | public function getAnyElement() |
||
| 543 | |||
| 544 | /** |
||
| 545 | * Sets a new anyElement |
||
| 546 | * |
||
| 547 | * @param mixed[] $anyElement |
||
| 548 | * @return self |
||
| 549 | */ |
||
| 550 | public function setAnyElement(array $anyElement) |
||
| 555 | |||
| 556 | |||
| 557 | } |
||
| 558 | |||
| 559 |
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..