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 |
||
| 11 | final class ServiceServiceProvider extends AbstractServiceProvider |
||
| 12 | { |
||
| 13 | /** |
||
| 14 | * @var array |
||
| 15 | */ |
||
| 16 | private $config; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * @api |
||
| 20 | * |
||
| 21 | * @param ServiceConfig $config |
||
| 22 | */ |
||
| 23 | public function __construct(ServiceConfig $config) |
||
| 28 | |||
| 29 | public function register() |
||
| 35 | |||
| 36 | /** |
||
| 37 | * @param ServiceDefinition $definition |
||
| 38 | * |
||
| 39 | * @return void |
||
| 40 | * |
||
| 41 | * @throws NotClassDefinitionException |
||
| 42 | */ |
||
| 43 | private function registerService(ServiceDefinition $definition) |
||
| 68 | |||
| 69 | /** |
||
| 70 | * @param ClassDefinition $service |
||
| 71 | * @param ServiceDefinition $definition |
||
| 72 | */ |
||
| 73 | private function addMethodCalls(ClassDefinition $service, ServiceDefinition $definition) |
||
| 79 | |||
| 80 | /** |
||
| 81 | * @param ServiceDefinition $definition |
||
| 82 | * |
||
| 83 | * @return \Closure |
||
| 84 | */ |
||
| 85 | View Code Duplication | private function createFactoryFactory(ServiceDefinition $definition) |
|
| 94 | |||
| 95 | /** |
||
| 96 | * @param array $arguments |
||
| 97 | * |
||
| 98 | * @return array |
||
| 99 | */ |
||
| 100 | View Code Duplication | private function resolveArguments(array $arguments) |
|
| 113 | } |
||
| 114 |
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..