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 |
||
| 10 | class TimeDataCollectorTest extends SapphireTest |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * @var DebugBarTimeDataCollector |
||
| 14 | */ |
||
| 15 | protected $collector; |
||
| 16 | |||
| 17 | public function setUp() |
||
| 22 | |||
| 23 | public function testCollectorTooltip() |
||
| 28 | |||
| 29 | /** |
||
| 30 | * Deliberately low threshold - should return a danger result |
||
| 31 | */ |
||
| 32 | public function testDangerOnVerySlowRequest() |
||
| 39 | |||
| 40 | /** |
||
| 41 | * Deliberately high threshold and low ratio - should return a warning result |
||
| 42 | */ |
||
| 43 | View Code Duplication | public function testWarningOnSlowRequest() |
|
| 51 | |||
| 52 | /** |
||
| 53 | * Deliberately high threshold and high ratio - should return an "ok" result |
||
| 54 | */ |
||
| 55 | View Code Duplication | public function testOkOnNormalRequest() |
|
| 63 | |||
| 64 | public function testWarningCanBeDisabled() |
||
| 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..