| Conditions | 1 |
| Paths | 1 |
| Total Lines | 89 |
| Code Lines | 56 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 |
||
| 93 | public function gsDataProvider() |
||
| 94 | { |
||
| 95 | return [ |
||
| 96 | 'default' => [ |
||
| 97 | [ |
||
| 98 | (object) [ |
||
| 99 | 'field1' => 'value1' |
||
| 100 | ], |
||
| 101 | (object) [ |
||
| 102 | 'field1' => 'second-value1' |
||
| 103 | ] |
||
| 104 | ], |
||
| 105 | null, |
||
| 106 | null |
||
| 107 | ], |
||
| 108 | 'group-hans' => [ |
||
| 109 | [ |
||
| 110 | (object) [ |
||
| 111 | 'field1' => 'value1', |
||
| 112 | 'field2' => 'value2', |
||
| 113 | 'field4' => 'value4' |
||
| 114 | ], |
||
| 115 | (object) [ |
||
| 116 | 'field1' => 'second-value1', |
||
| 117 | 'field2' => 'second-value2', |
||
| 118 | 'field4' => 'second-value4' |
||
| 119 | ] |
||
| 120 | ], |
||
| 121 | 'hans', |
||
| 122 | null |
||
| 123 | ], |
||
| 124 | 'group-fred' => [ |
||
| 125 | [ |
||
| 126 | (object) [ |
||
| 127 | 'field1' => 'value1', |
||
| 128 | 'field3' => 'value3', |
||
| 129 | 'field4' => 'value4' |
||
| 130 | ], |
||
| 131 | (object) [ |
||
| 132 | 'field1' => 'second-value1', |
||
| 133 | 'field3' => 'second-value3', |
||
| 134 | 'field4' => 'second-value4' |
||
| 135 | ] |
||
| 136 | ], |
||
| 137 | 'fred', |
||
| 138 | null |
||
| 139 | ], |
||
| 140 | 'group-hans-fred' => [ |
||
| 141 | [ |
||
| 142 | (object) [ |
||
| 143 | 'field1' => 'value1', |
||
| 144 | 'field2' => 'value2', |
||
| 145 | 'field3' => 'value3', |
||
| 146 | 'field4' => 'value4' |
||
| 147 | ], |
||
| 148 | (object) [ |
||
| 149 | 'field1' => 'second-value1', |
||
| 150 | 'field2' => 'second-value2', |
||
| 151 | 'field3' => 'second-value3', |
||
| 152 | 'field4' => 'second-value4' |
||
| 153 | ] |
||
| 154 | ], |
||
| 155 | 'hans, fred', |
||
| 156 | null |
||
| 157 | ], |
||
| 158 | 'group-hans-rql-not-allowed-field' => [ |
||
| 159 | [ |
||
| 160 | (object) [ |
||
| 161 | ], |
||
| 162 | (object) [ |
||
| 163 | ] |
||
| 164 | ], |
||
| 165 | 'hans', |
||
| 166 | 'select(field3)' |
||
| 167 | ], |
||
| 168 | 'group-fred-rql-allowed-field' => [ |
||
| 169 | [ |
||
| 170 | (object) [ |
||
| 171 | 'field3' => 'value3' |
||
| 172 | ], |
||
| 173 | (object) [ |
||
| 174 | 'field3' => 'second-value3' |
||
| 175 | ] |
||
| 176 | ], |
||
| 177 | 'fred', |
||
| 178 | 'select(field3)' |
||
| 179 | ] |
||
| 180 | ]; |
||
| 181 | } |
||
| 182 | } |
||
| 183 |
This check looks for the generic type
arrayas a return type and suggests a more specific type. This type is inferred from the actual code.