Conditions | 1 |
Paths | 1 |
Total Lines | 66 |
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 |
||
11 | public function __construct($name, ServiceManager $sm, Translator $translator) |
||
12 | { |
||
13 | $this->setServiceManager($sm); |
||
14 | $entityManager = $sm->get('doctrine.entitymanager.orm_default'); |
||
15 | |||
16 | // Mapping of an Entity to get value by getId()... Should be taken in charge by Doctrine Hydrator Strategy... |
||
17 | // having to fix a DoctrineModule bug :( https://github.com/doctrine/DoctrineModule/issues/180 |
||
18 | $hydrator = new DoctrineHydrator($entityManager, 'PlaygroundGame\Entity\PostVote'); |
||
|
|||
19 | $hydrator->addStrategy('partner', new \PlaygroundCore\Stdlib\Hydrator\Strategy\ObjectStrategy()); |
||
20 | $this->setHydrator($hydrator); |
||
21 | |||
22 | parent::__construct($name, $sm, $translator); |
||
23 | |||
24 | $this->add(array( |
||
25 | 'type' => 'Zend\Form\Element\Select', |
||
26 | 'name' => 'postDisplayMode', |
||
27 | 'attributes' => array( |
||
28 | 'id' => 'postDisplayMode', |
||
29 | 'options' => array( |
||
30 | 'date' => $translator->translate('Date', 'playgroundgame'), |
||
31 | 'vote' => $translator->translate('Vote number', 'playgroundgame'), |
||
32 | 'random' => $translator->translate('Random', 'playgroundgame'), |
||
33 | ), |
||
34 | ), |
||
35 | 'options' => array( |
||
36 | 'empty_option' => $translator->translate('Display posts orber by', 'playgroundgame'), |
||
37 | 'label' => $translator->translate('Posts display mode', 'playgroundgame'), |
||
38 | ), |
||
39 | )); |
||
40 | |||
41 | $this->add(array( |
||
42 | 'type' => 'Zend\Form\Element\Text', |
||
43 | 'name' => 'postDisplayNumber', |
||
44 | 'attributes' => array( |
||
45 | 'id' => 'postDisplayNumber', |
||
46 | ), |
||
47 | 'options' => array( |
||
48 | 'empty_option' => $translator->translate('Number of displayed posts', 'playgroundgame'), |
||
49 | 'label' => $translator->translate('Number of displayed posts', 'playgroundgame'), |
||
50 | ), |
||
51 | )); |
||
52 | |||
53 | $this->add(array( |
||
54 | 'type' => 'Zend\Form\Element\Checkbox', |
||
55 | 'name' => 'voteAnonymous', |
||
56 | 'options' => array( |
||
57 | 'label' => $translator->translate('Allow anonymous visitors to vote', 'playgroundgame'), |
||
58 | ), |
||
59 | )); |
||
60 | |||
61 | $this->add(array( |
||
62 | 'type' => 'Zend\Form\Element\Select', |
||
63 | 'name' => 'moderationType', |
||
64 | 'attributes' => array( |
||
65 | 'id' => 'moderationType', |
||
66 | 'options' => array( |
||
67 | '0' => $translator->translate('Post moderation', 'playgroundgame'), |
||
68 | '1' => $translator->translate('Pre moderation', 'playgroundgame'), |
||
69 | ), |
||
70 | ), |
||
71 | 'options' => array( |
||
72 | 'empty_option' => $translator->translate('Moderation type', 'playgroundgame'), |
||
73 | 'label' => $translator->translate('Moderation type', 'playgroundgame'), |
||
74 | ), |
||
75 | )); |
||
76 | } |
||
77 | } |
||
78 |
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: