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 | class Hydrate extends ConfigureActionCommand |
||
12 | { |
||
13 | 36 | public function __construct(Application $app) |
|
22 | |||
23 | 10 | protected function getProcessor(): ConfigurableProcessor |
|
27 | |||
28 | 10 | protected function launchConfigurationAction(ConfigurableProcessor $processor): void |
|
37 | |||
38 | 10 | View Code Duplication | private function warnForUnusedVariables(Hydrator $processor): void |
54 | |||
55 | 10 | View Code Duplication | private function warnForUnvaluedVariables(Hydrator $processor): void |
69 | } |
||
70 |
This error could be the result of:
1. Missing dependencies
PHP Analyzer uses your
composer.json
file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects thecomposer.json
to be in the root folder of your repository.Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the
require
orrequire-dev
section?2. Missing use statement
PHP does not complain about undefined classes in
ìnstanceof
checks. For example, the following PHP code will work perfectly fine:If you have not tested against this specific condition, such errors might go unnoticed.