| Conditions | 15 |
| Paths | 17 |
| Total Lines | 57 |
| Code Lines | 34 |
| 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 |
||
| 77 | protected function adjustGlobalQuery() |
||
| 78 | { |
||
| 79 | global $conf, $INPUT, $QUERY; |
||
| 80 | |||
| 81 | if ($INPUT->bool('searchPageForm')) { |
||
| 82 | return; |
||
| 83 | } |
||
| 84 | |||
| 85 | $Indexer = idx_get_indexer(); |
||
| 86 | $parsedQuery = ft_queryParser($Indexer, $QUERY); |
||
| 87 | |||
| 88 | if (empty($parsedQuery['ns']) && empty($parsedQuery['notns'])) { |
||
| 89 | if ($conf['search_limit_to_first_ns'] > 0) { |
||
| 90 | $searchOriginPage = $INPUT->str('from'); |
||
| 91 | if (getNS($searchOriginPage) !== false) { |
||
| 92 | $nsParts = explode(':', getNS($searchOriginPage)); |
||
| 93 | $ns = implode(':', array_slice($nsParts, 0, $conf['search_limit_to_first_ns'])); |
||
| 94 | $QUERY .= " @$ns"; |
||
| 95 | } |
||
| 96 | } |
||
| 97 | } |
||
| 98 | |||
| 99 | if ($conf['search_default_fragment_behaviour'] !== 'exact') { |
||
| 100 | if (empty(array_diff($parsedQuery['words'], $parsedQuery['and']))) { |
||
| 101 | if (strpos($QUERY, '*') === false) { |
||
| 102 | $queryParts = explode(' ', $QUERY); |
||
| 103 | $queryParts = array_map(function ($part) { |
||
| 104 | if (strpos($part, '@') === 0) { |
||
| 105 | return $part; |
||
| 106 | } |
||
| 107 | if (strpos($part, 'ns:') === 0) { |
||
| 108 | return $part; |
||
| 109 | } |
||
| 110 | if (strpos($part, '^') === 0) { |
||
| 111 | return $part; |
||
| 112 | } |
||
| 113 | if (strpos($part, '-ns:') === 0) { |
||
| 114 | return $part; |
||
| 115 | } |
||
| 116 | |||
| 117 | global $conf; |
||
| 118 | |||
| 119 | if ($conf['search_default_fragment_behaviour'] === 'starts_with') { |
||
| 120 | return $part . '*'; |
||
| 121 | } |
||
| 122 | if ($conf['search_default_fragment_behaviour'] === 'ends_with') { |
||
| 123 | return '*' . $part; |
||
| 124 | } |
||
| 125 | |||
| 126 | return '*' . $part . '*'; |
||
| 127 | |||
| 128 | }, $queryParts); |
||
| 129 | $QUERY = implode(' ', $queryParts); |
||
| 130 | } |
||
| 131 | } |
||
| 132 | } |
||
| 133 | } |
||
| 134 | } |
||
| 135 |
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: