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 |
||
24 | class SchemaExportCommand extends Command |
||
25 | { |
||
26 | |||
27 | /** |
||
28 | * @var documentManager |
||
29 | */ |
||
30 | private $documentManager; |
||
31 | |||
32 | /** |
||
33 | * @var Filesystem |
||
34 | */ |
||
35 | private $fileSystem; |
||
36 | |||
37 | /** |
||
38 | * GenerateBuildIndexesCommand constructor. |
||
39 | * |
||
40 | * @param DocumentManager $documentManager The Doctrine Document Manager |
||
41 | * @param Filesystem $fileSystem Sf file manager |
||
42 | * @param String $name The Name of this Command |
||
|
|||
43 | */ |
||
44 | 4 | public function __construct( |
|
54 | |||
55 | /** |
||
56 | * {@inheritDoc} |
||
57 | * |
||
58 | * @return void |
||
59 | */ |
||
60 | 4 | protected function configure() |
|
70 | |||
71 | /** |
||
72 | * {@inheritDoc} |
||
73 | * |
||
74 | * @param InputInterface $input input |
||
75 | * @param OutputInterface $output output |
||
76 | * |
||
77 | * @return void |
||
78 | */ |
||
79 | protected function execute(InputInterface $input, OutputInterface $output) |
||
113 | |||
114 | /** |
||
115 | * Gets the installed MongoDB Version |
||
116 | * @param String $className The Classname of the collection, needed to fetch the right DB connection |
||
117 | * @return String getMongoDBVersion The version of the MongoDB as a string |
||
118 | */ |
||
119 | View Code Duplication | private function getMongoDBVersion($className) |
|
128 | } |
||
129 |
This check looks for
@param
annotations where the type inferred by our type inference engine differs from the declared type.It makes a suggestion as to what type it considers more descriptive.
Most often this is a case of a parameter that can be null in addition to its declared types.