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 |
||
| 8 | class AccessToken extends CoreAccessToken |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * API. |
||
| 12 | */ |
||
| 13 | const API_TOKEN_GET = 'https://qyapi.weixin.qq.com/cgi-bin/service/get_suite_token'; |
||
| 14 | /** |
||
| 15 | * Ticket. |
||
| 16 | * |
||
| 17 | * @var \EntWeChat\Suite\Ticket |
||
| 18 | */ |
||
| 19 | protected $ticket; |
||
| 20 | /** |
||
| 21 | * {@inheritdoc}. |
||
| 22 | */ |
||
| 23 | protected $queryName = 'suite_access_token'; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * {@inheritdoc}. |
||
| 27 | */ |
||
| 28 | protected $tokenJsonKey = 'suite_access_token'; |
||
| 29 | |||
| 30 | /** |
||
| 31 | * {@inheritdoc}. |
||
| 32 | */ |
||
| 33 | protected $prefix = 'YEntWeChat.suite.suite_access_token.'; |
||
| 34 | |||
| 35 | /** |
||
| 36 | * Set VerifyTicket. |
||
| 37 | * |
||
| 38 | * @param \EntWeChat\Suite\Ticket $ticket |
||
| 39 | * |
||
| 40 | * @return $this |
||
| 41 | */ |
||
| 42 | public function setTicket(Ticket $ticket) |
||
| 48 | |||
| 49 | /** |
||
| 50 | * {@inheritdoc}. |
||
| 51 | */ |
||
| 52 | View Code Duplication | public function getTokenFromServer() |
|
| 70 | } |
||
| 71 |
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..