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 |
||
17 | class HeaderFieldStrategyTest extends WebTestCase |
||
18 | { |
||
19 | /** |
||
20 | * @covers \Graviton\SecurityBundle\Authentication\Strategies\HeaderFieldStrategy::apply |
||
21 | * @covers \Graviton\SecurityBundle\Authentication\Strategies\AbstractHttpStrategy::extractFieldInfo |
||
22 | * @covers \Graviton\SecurityBundle\Authentication\Strategies\AbstractHttpStrategy::validateField |
||
23 | * |
||
24 | * @dataProvider stringProvider |
||
25 | * |
||
26 | * @param string $headerFieldValue header to test with |
||
27 | * |
||
28 | * @return void |
||
29 | */ |
||
30 | public function testApply($headerFieldValue) |
||
54 | |||
55 | /** |
||
56 | * @return array<string> |
||
57 | */ |
||
58 | View Code Duplication | public function stringProvider() |
|
67 | } |
||
68 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: