@@ -40,12 +40,12 @@ Suppose you have a Task form with a tags ``text`` type::
40
40
// ...
41
41
class TaskType extends AbstractType
42
42
{
43
- public function buildForm(FormBuilderInterface $builder, array $options)
43
+ public function buildForm(FormBuilderInterface $builder, array $options): void
44
44
{
45
45
$builder->add('tags', TextType::class);
46
46
}
47
47
48
- public function configureOptions(OptionsResolver $resolver)
48
+ public function configureOptions(OptionsResolver $resolver): void
49
49
{
50
50
$resolver->setDefaults([
51
51
'data_class' => Task::class,
@@ -72,7 +72,7 @@ class::
72
72
73
73
class TaskType extends AbstractType
74
74
{
75
- public function buildForm(FormBuilderInterface $builder, array $options)
75
+ public function buildForm(FormBuilderInterface $builder, array $options): void
76
76
{
77
77
$builder->add('tags', TextType::class);
78
78
@@ -136,15 +136,15 @@ Start by setting up the text field like normal::
136
136
// ...
137
137
class TaskType extends AbstractType
138
138
{
139
- public function buildForm(FormBuilderInterface $builder, array $options)
139
+ public function buildForm(FormBuilderInterface $builder, array $options): void
140
140
{
141
141
$builder
142
142
->add('description', TextareaType::class)
143
143
->add('issue', TextType::class)
144
144
;
145
145
}
146
146
147
- public function configureOptions(OptionsResolver $resolver)
147
+ public function configureOptions(OptionsResolver $resolver): void
148
148
{
149
149
$resolver->setDefaults([
150
150
'data_class' => Task::class,
@@ -188,9 +188,8 @@ to and from the issue number and the ``Issue`` object::
188
188
* Transforms an object (issue) to a string (number).
189
189
*
190
190
* @param Issue|null $issue
191
- * @return string
192
191
*/
193
- public function transform($issue)
192
+ public function transform($issue): string
194
193
{
195
194
if (null === $issue) {
196
195
return '';
@@ -203,10 +202,9 @@ to and from the issue number and the ``Issue`` object::
203
202
* Transforms a string (number) to an object (issue).
204
203
*
205
204
* @param string $issueNumber
206
- * @return Issue|null
207
205
* @throws TransformationFailedException if object (issue) is not found.
208
206
*/
209
- public function reverseTransform($issueNumber)
207
+ public function reverseTransform($issueNumber): ?Issue
210
208
{
211
209
// no issue number? It's optional, so that's ok
212
210
if (!$issueNumber) {
@@ -273,7 +271,7 @@ and type-hint the new class::
273
271
$this->transformer = $transformer;
274
272
}
275
273
276
- public function buildForm(FormBuilderInterface $builder, array $options)
274
+ public function buildForm(FormBuilderInterface $builder, array $options): void
277
275
{
278
276
$builder
279
277
->add('description', TextareaType::class)
@@ -306,7 +304,7 @@ end-user error message in the data transformer using the
306
304
{
307
305
// ...
308
306
309
- public function reverseTransform($issueNumber)
307
+ public function reverseTransform($issueNumber): ?Issue
310
308
{
311
309
// ...
312
310
@@ -394,19 +392,19 @@ First, create the custom field type class::
394
392
$this->transformer = $transformer;
395
393
}
396
394
397
- public function buildForm(FormBuilderInterface $builder, array $options)
395
+ public function buildForm(FormBuilderInterface $builder, array $options): void
398
396
{
399
397
$builder->addModelTransformer($this->transformer);
400
398
}
401
399
402
- public function configureOptions(OptionsResolver $resolver)
400
+ public function configureOptions(OptionsResolver $resolver): void
403
401
{
404
402
$resolver->setDefaults([
405
403
'invalid_message' => 'The selected issue does not exist',
406
404
]);
407
405
}
408
406
409
- public function getParent()
407
+ public function getParent(): string
410
408
{
411
409
return TextType::class;
412
410
}
@@ -427,7 +425,7 @@ As long as you're using :ref:`autowire <services-autowire>` and
427
425
428
426
class TaskType extends AbstractType
429
427
{
430
- public function buildForm(FormBuilderInterface $builder, array $options)
428
+ public function buildForm(FormBuilderInterface $builder, array $options): void
431
429
{
432
430
$builder
433
431
->add('description', TextareaType::class)
0 commit comments