Conditions | 1 |
Paths | 1 |
Total Lines | 64 |
Code Lines | 43 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 1 | 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 |
||
14 | public function __construct($name, ServiceManager $serviceManager, Translator $translator) |
||
15 | { |
||
16 | parent::__construct($name); |
||
17 | $entityManager = $serviceManager->get('doctrine.entitymanager.orm_default'); |
||
18 | |||
19 | $this->setHydrator(new DoctrineHydrator($entityManager, 'PlaygroundGame\Entity\MissionGame')) |
||
|
|||
20 | ->setObject(new MissionGame()); |
||
21 | |||
22 | $this->add(array( |
||
23 | 'type' => 'Zend\Form\Element\Hidden', |
||
24 | 'name' => 'id' |
||
25 | )); |
||
26 | |||
27 | $this->add(array( |
||
28 | 'name' => 'game', |
||
29 | 'type' => 'DoctrineModule\Form\Element\ObjectSelect', |
||
30 | 'options' => array( |
||
31 | 'empty_option' => $translator->translate('Select a game', 'playgroundgame'), |
||
32 | 'label' => $translator->translate('Game', 'playgroundgame'), |
||
33 | 'object_manager' => $entityManager, |
||
34 | 'target_class' => 'PlaygroundGame\Entity\Game', |
||
35 | 'property' => 'title' |
||
36 | ), |
||
37 | 'attributes' => array( |
||
38 | 'required' => false, |
||
39 | //'multiple' => 'multiple', |
||
40 | ) |
||
41 | )); |
||
42 | |||
43 | $this->add(array( |
||
44 | 'type' => 'Zend\Form\Element\Hidden', |
||
45 | 'name' => 'position', |
||
46 | 'attributes' => array( |
||
47 | 'id' => 'position__index__', |
||
48 | ), |
||
49 | )); |
||
50 | |||
51 | $gameMissionConditionFieldset = new MissionGameConditionFieldset(null, $serviceManager, $translator); |
||
52 | $this->add(array( |
||
53 | 'type' => 'Zend\Form\Element\Collection', |
||
54 | 'name' => 'conditions', |
||
55 | 'options' => array( |
||
56 | 'id' => 'conditions', |
||
57 | 'label' => $translator->translate('List of conditions', 'playgroundgame'), |
||
58 | 'count' => 0, |
||
59 | 'should_create_template' => true, |
||
60 | 'allow_add' => true, |
||
61 | 'allow_remove' => true, |
||
62 | 'target_element' => $gameMissionConditionFieldset |
||
63 | ) |
||
64 | )); |
||
65 | |||
66 | $this->add(array( |
||
67 | 'type' => 'Zend\Form\Element\Button', |
||
68 | 'name' => 'add_condition', |
||
69 | 'options' => array( |
||
70 | 'label' => $translator->translate('Add Condition', 'playgroundgame'), |
||
71 | ), |
||
72 | 'attributes' => array( |
||
73 | 'class' => 'addCondition', |
||
74 | ) |
||
75 | )); |
||
76 | |||
77 | } |
||
78 | |||
84 |
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: