| Conditions | 1 |
| Paths | 1 |
| Total Lines | 59 |
| Code Lines | 29 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
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 |
||
| 14 | public function setUp() { |
||
| 15 | parent::setUp(); |
||
| 16 | /** |
||
| 17 | * @var \phpbb\user $user Mock the user class |
||
| 18 | */ |
||
| 19 | $user = $this->getMock('\phpbb\user', array(), array('\phpbb\datetime')); |
||
| 20 | |||
| 21 | /** |
||
| 22 | * @var \phpbb\request\request $request |
||
| 23 | */ |
||
| 24 | $request = $this->getMockBuilder('\phpbb\request\request') |
||
| 25 | ->disableOriginalConstructor() |
||
| 26 | ->getMock(); |
||
| 27 | |||
| 28 | /** |
||
| 29 | * @var \florinp\messenger\models\main_model $model |
||
| 30 | */ |
||
| 31 | $model = $this->getMockBuilder('\florinp\messenger\models\main_model') |
||
| 32 | ->disableOriginalConstructor() |
||
| 33 | ->getMock(); |
||
| 34 | |||
| 35 | /** |
||
| 36 | * @var \phpbb\notification\manager $notification_manager |
||
| 37 | */ |
||
| 38 | $notification_manager = $this->getMockBuilder('\phpbb\notification\manager') |
||
| 39 | ->disableOriginalConstructor() |
||
| 40 | ->getMock(); |
||
| 41 | |||
| 42 | /** |
||
| 43 | * @var \florinp\messenger\libs\emojione $emojione |
||
| 44 | */ |
||
| 45 | $emojione = $this->getMockBuilder('\florinp\messenger\libs\emojione') |
||
| 46 | ->disableOriginalConstructor() |
||
| 47 | ->getMock(); |
||
| 48 | |||
| 49 | /** |
||
| 50 | * @var \florinp\messenger\libs\upload $upload |
||
| 51 | */ |
||
| 52 | $upload = $this->getMockBuilder('\florinp\messenger\libs\upload') |
||
| 53 | ->disableOriginalConstructor() |
||
| 54 | ->getMock(); |
||
| 55 | |||
| 56 | /** |
||
| 57 | * @var \florinp\messenger\libs\download $download |
||
| 58 | */ |
||
| 59 | $download = $this->getMockBuilder('\florinp\messenger\libs\download') |
||
| 60 | ->disableOriginalConstructor() |
||
| 61 | ->getMock(); |
||
| 62 | |||
| 63 | $this->controller = new \florinp\messenger\controller\main( |
||
| 64 | $request, |
||
| 65 | $user, |
||
| 66 | $model, |
||
| 67 | $notification_manager, |
||
| 68 | $emojione, |
||
| 69 | $upload, |
||
|
|
|||
| 70 | $download |
||
| 71 | ); |
||
| 72 | } |
||
| 73 | |||
| 119 | } |
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: