Conditions | 1 |
Paths | 1 |
Total Lines | 59 |
Code Lines | 39 |
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 |
||
33 | protected function build($builder) |
||
34 | { |
||
35 | return $builder |
||
36 | ->add('domain', TextType::class, [ |
||
37 | 'constraints' => [ |
||
38 | new NotBlank(), |
||
39 | new Length([ |
||
40 | 'max' => 50, |
||
41 | ]), |
||
42 | ], |
||
43 | ]) |
||
44 | ->add( |
||
45 | $builder->create('port', IntegerType::class, array( |
||
|
|||
46 | 'constraints' => new NotBlank(), |
||
47 | 'data' => 5154 |
||
48 | ))->setDataLocked(false) // Don't lock the data so we can change the default value later if needed |
||
49 | ) |
||
50 | ->add('name', TextType::class, [ |
||
51 | 'constraints' => [ |
||
52 | new NotBlank(), |
||
53 | new Length([ |
||
54 | 'max' => 100, |
||
55 | ]), |
||
56 | ], |
||
57 | ]) |
||
58 | ->add('country', new ModelType('Country'), [ |
||
59 | 'constraints' => [ |
||
60 | new NotBlank(), |
||
61 | ], |
||
62 | ]) |
||
63 | ->add('owner', new AdvancedModelType('Player'), [ |
||
64 | 'constraints' => [ |
||
65 | new NotBlank(), |
||
66 | ], |
||
67 | ]) |
||
68 | ->add('server_type', ChoiceType::class, [ |
||
69 | 'choices' => [ |
||
70 | self::OFFICIAL_MATCH_SERVER => 'Official Match Server', |
||
71 | self::OFFICIAL_REPLAY_SERVER => 'Official Replay Server', |
||
72 | self::PUBLIC_SERVER => 'Public Server', |
||
73 | self::PUBLIC_REPLAY_SERVER => 'Public Replay Server', |
||
74 | ], |
||
75 | 'required' => true, |
||
76 | 'label' => 'Server Type', |
||
77 | ]) |
||
78 | ->add('inactive', CheckboxType::class, [ |
||
79 | 'label' => 'Server Inactive', |
||
80 | 'required' => false, |
||
81 | 'attr' => [ |
||
82 | 'data-help-message' => 'When checked, that means this server is no longer active in hosting', |
||
83 | ], |
||
84 | ]) |
||
85 | ->add('enter', SubmitType::class, [ |
||
86 | 'attr' => [ |
||
87 | 'class' => 'c-button--blue pattern pattern--downward-stripes', |
||
88 | ], |
||
89 | ]) |
||
90 | ; |
||
91 | } |
||
92 | |||
193 |
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: