| Conditions | 1 |
| Paths | 1 |
| Total Lines | 51 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 62 | public function getFilters() |
||
| 63 | { |
||
| 64 | return [ |
||
| 65 | [ChoiceType::TYPE_EQUAL, [ |
||
| 66 | 'where.constraint.operand_dynamic' => [ |
||
| 67 | 'getAlias' => 'a', |
||
| 68 | 'getField' => 'somefield', |
||
| 69 | ], |
||
| 70 | 'where.constraint.operand_static' => [ |
||
| 71 | 'getValue' => 'somevalue', |
||
| 72 | ], |
||
| 73 | ]], |
||
| 74 | [ChoiceType::TYPE_NOT_CONTAINS, [ |
||
| 75 | 'where.constraint' => [ |
||
| 76 | 'getField' => 'somefield', |
||
| 77 | 'getFullTextSearchExpression' => '* -somevalue', ], |
||
| 78 | ]], |
||
| 79 | [ChoiceType::TYPE_CONTAINS, [ |
||
| 80 | 'where.constraint.operand_dynamic' => [ |
||
| 81 | 'getAlias' => 'a', |
||
| 82 | 'getField' => 'somefield', |
||
| 83 | ], |
||
| 84 | 'where.constraint.operand_static' => [ |
||
| 85 | 'getValue' => '%somevalue%', |
||
| 86 | ], |
||
| 87 | ]], |
||
| 88 | [ChoiceType::TYPE_CONTAINS_WORDS, [ |
||
| 89 | 'where.constraint' => [ |
||
| 90 | 'getField' => 'somefield', |
||
| 91 | 'getFullTextSearchExpression' => 'somevalue', ], |
||
| 92 | ]], |
||
| 93 | 'equalCaseInsensitiveComparision' => [ChoiceType::TYPE_EQUAL, [ |
||
| 94 | 'where.constraint.operand_dynamic.operand_dynamic' => [ |
||
| 95 | 'getAlias' => 'a', |
||
| 96 | 'getField' => 'somefield', |
||
| 97 | ], |
||
| 98 | 'where.constraint.operand_static' => [ |
||
| 99 | 'getValue' => 'somevalue', |
||
| 100 | ], |
||
| 101 | ], true], |
||
| 102 | 'containsCaseInsensitiveComparision' => [ChoiceType::TYPE_CONTAINS, [ |
||
| 103 | 'where.constraint.operand_dynamic.operand_dynamic' => [ |
||
| 104 | 'getAlias' => 'a', |
||
| 105 | 'getField' => 'somefield', |
||
| 106 | ], |
||
| 107 | 'where.constraint.operand_static' => [ |
||
| 108 | 'getValue' => '%somevalue%', |
||
| 109 | ], |
||
| 110 | ], true], |
||
| 111 | ]; |
||
| 112 | } |
||
| 113 | |||
| 141 |
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: