Conditions | 1 |
Paths | 1 |
Total Lines | 72 |
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 |
||
182 | public function dataProviderForShouldCreateCallArgumentFromArray(): array |
||
183 | { |
||
184 | return array( |
||
185 | [null, [], true], |
||
186 | [null, ['method' => 'foo'], true], |
||
187 | [null, ['callee' => 'bar'], true], |
||
188 | [new ArgumentCall( |
||
189 | $this->createMock(ArgumentCompilerInterface::class), |
||
190 | $this->createMock(Argument::class), |
||
191 | 'someMethod', |
||
192 | [] |
||
193 | ), [ |
||
194 | 'callee' => 'some-callee', |
||
195 | 'method' => 'someMethod' |
||
196 | ], false], |
||
197 | [new ArgumentCall( |
||
198 | $this->createMock(ArgumentCompilerInterface::class), |
||
199 | $this->createMock(Argument::class), |
||
200 | 'someMethod', |
||
201 | [] |
||
202 | ), [ |
||
203 | 'callee' => ['some-callee'], |
||
204 | 'method' => 'someMethod' |
||
205 | ], false], |
||
206 | [new ArgumentCall( |
||
207 | $this->createMock(ArgumentCompilerInterface::class), |
||
208 | $this->createMock(Argument::class), |
||
209 | 'someMethod', |
||
210 | [ |
||
211 | $this->createMock(Argument::class), |
||
212 | $this->createMock(Argument::class) |
||
213 | ] |
||
214 | ), [ |
||
215 | 'callee' => 'some-callee', |
||
216 | 'method' => 'someMethod', |
||
217 | 'arguments' => [ |
||
218 | 'foo', |
||
219 | 'bar' |
||
220 | ] |
||
221 | ], false], |
||
222 | [new ArgumentCall( |
||
223 | $this->createMock(ArgumentCompilerInterface::class), |
||
224 | $this->createMock(Argument::class), |
||
225 | 'someMethod', [ |
||
226 | $this->createMock(Argument::class), |
||
227 | $this->createMock(Argument::class) |
||
228 | ] |
||
229 | ), [ |
||
230 | 'callee' => ['some-callee'], |
||
231 | 'method' => 'someMethod', |
||
232 | 'arguments' => [ |
||
233 | 'foo', |
||
234 | 'bar' |
||
235 | ] |
||
236 | ], false], |
||
237 | [new ArgumentCall( |
||
238 | $this->createMock(ArgumentCompilerInterface::class), |
||
239 | $this->createMock(Argument::class), |
||
240 | 'someMethod', [ |
||
241 | $this->createMock(Argument::class), |
||
242 | $this->createMock(Argument::class) |
||
243 | ] |
||
244 | ), [ |
||
245 | 'callee' => 'some-callee', |
||
246 | 'method' => 'someMethod', |
||
247 | 'arguments' => [ |
||
248 | ['foo'], |
||
249 | ['bar'] |
||
250 | ] |
||
251 | ], false], |
||
252 | ); |
||
253 | } |
||
254 | |||
256 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..