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 | ||
| 9 | final class PaymentResourceTest extends TestCase | ||
| 10 | { | ||
| 11 | /** | ||
| 12 | * @var BunqClient | ||
| 13 | */ | ||
| 14 | private $bunqClient; | ||
| 15 | |||
| 16 | /** | ||
| 17 | * @var PaymentResource | ||
| 18 | */ | ||
| 19 | private $resource; | ||
| 20 | |||
| 21 | public function setUp() | ||
| 26 | |||
| 27 | /** | ||
| 28 | * @test | ||
| 29 | */ | ||
| 30 | View Code Duplication | public function itReturnsAListOfPayments() | |
| 64 | |||
| 65 | /** | ||
| 66 | * @test | ||
| 67 | */ | ||
| 68 | public function itReturnsASinglePayment() | ||
| 97 | } | ||
| 98 | 
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..