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 LanguageManager extends RepositoryExecutor |
||
12 | { |
||
13 | protected $supportedStepTypes = array('language'); |
||
14 | protected $supportedActions = array('create', 'delete'); |
||
15 | |||
16 | /** |
||
17 | * Handles the language create migration action |
||
18 | */ |
||
19 | protected function create($step) |
||
41 | |||
42 | /** |
||
43 | * Handles the language update migration action |
||
44 | * |
||
45 | * @todo use a matcher for flexible matching? |
||
46 | */ |
||
47 | protected function update($step) |
||
59 | |||
60 | /** |
||
61 | * Handles the language delete migration action |
||
62 | * |
||
63 | * @todo use a matcher for flexible matching? |
||
64 | */ |
||
65 | protected function delete($step) |
||
78 | |||
79 | /** |
||
80 | * @param Language $language |
||
81 | * @param array $references the definitions of the references to set |
||
82 | * @throws \InvalidArgumentException When trying to assign a reference to an unsupported attribute |
||
83 | * @return array key: the reference names, values: the reference values |
||
84 | */ |
||
85 | protected function getReferencesValues(Language $language, array $references) |
||
115 | } |
||
116 |
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: