Skip to content

Commit b8d7a89

Browse files
wouterjnicolas-grekas
authored andcommitted
Add PHP types to private methods and functions
1 parent d78da77 commit b8d7a89

File tree

6 files changed

+24
-24
lines changed

6 files changed

+24
-24
lines changed

Console/Descriptor/Descriptor.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ abstract class Descriptor implements DescriptorInterface
4040
protected $parents = [];
4141
protected $extensions = [];
4242

43-
public function describe(OutputInterface $output, ?object $object, array $options = [])
43+
public function describe(OutputInterface $output, ?object $object, array $options = []): void
4444
{
4545
$this->output = $output instanceof OutputStyle ? $output : new SymfonyStyle(new ArrayInput([]), $output);
4646

@@ -52,13 +52,13 @@ public function describe(OutputInterface $output, ?object $object, array $option
5252
};
5353
}
5454

55-
abstract protected function describeDefaults(array $options);
55+
abstract protected function describeDefaults(array $options): void;
5656

57-
abstract protected function describeResolvedFormType(ResolvedFormTypeInterface $resolvedFormType, array $options = []);
57+
abstract protected function describeResolvedFormType(ResolvedFormTypeInterface $resolvedFormType, array $options = []): void;
5858

59-
abstract protected function describeOption(OptionsResolver $optionsResolver, array $options);
59+
abstract protected function describeOption(OptionsResolver $optionsResolver, array $options): void;
6060

61-
protected function collectOptions(ResolvedFormTypeInterface $type)
61+
protected function collectOptions(ResolvedFormTypeInterface $type): void
6262
{
6363
$this->parents = [];
6464
$this->extensions = [];
@@ -96,7 +96,7 @@ protected function collectOptions(ResolvedFormTypeInterface $type)
9696
$this->extensions = array_keys($this->extensions);
9797
}
9898

99-
protected function getOptionDefinition(OptionsResolver $optionsResolver, string $option)
99+
protected function getOptionDefinition(OptionsResolver $optionsResolver, string $option): array
100100
{
101101
$definition = [];
102102

@@ -139,7 +139,7 @@ protected function getOptionDefinition(OptionsResolver $optionsResolver, string
139139
return $definition;
140140
}
141141

142-
protected function filterOptionsByDeprecated(ResolvedFormTypeInterface $type)
142+
protected function filterOptionsByDeprecated(ResolvedFormTypeInterface $type): void
143143
{
144144
$deprecatedOptions = [];
145145
$resolver = $type->getOptionsResolver();
@@ -186,7 +186,7 @@ private function getParentOptionsResolver(ResolvedFormTypeInterface $type): Opti
186186
return $optionsResolver;
187187
}
188188

189-
private function collectTypeExtensionsOptions(ResolvedFormTypeInterface $type, OptionsResolver $optionsResolver)
189+
private function collectTypeExtensionsOptions(ResolvedFormTypeInterface $type, OptionsResolver $optionsResolver): void
190190
{
191191
foreach ($type->getTypeExtensions() as $extension) {
192192
$inheritedOptions = $optionsResolver->getDefinedOptions();

Console/Descriptor/JsonDescriptor.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
*/
2222
class JsonDescriptor extends Descriptor
2323
{
24-
protected function describeDefaults(array $options)
24+
protected function describeDefaults(array $options): void
2525
{
2626
$data['builtin_form_types'] = $options['core_types'];
2727
$data['service_form_types'] = $options['service_types'];
@@ -33,7 +33,7 @@ protected function describeDefaults(array $options)
3333
$this->writeData($data, $options);
3434
}
3535

36-
protected function describeResolvedFormType(ResolvedFormTypeInterface $resolvedFormType, array $options = [])
36+
protected function describeResolvedFormType(ResolvedFormTypeInterface $resolvedFormType, array $options = []): void
3737
{
3838
$this->collectOptions($resolvedFormType);
3939

@@ -61,7 +61,7 @@ protected function describeResolvedFormType(ResolvedFormTypeInterface $resolvedF
6161
$this->writeData($data, $options);
6262
}
6363

64-
protected function describeOption(OptionsResolver $optionsResolver, array $options)
64+
protected function describeOption(OptionsResolver $optionsResolver, array $options): void
6565
{
6666
$definition = $this->getOptionDefinition($optionsResolver, $options['option']);
6767

@@ -93,14 +93,14 @@ protected function describeOption(OptionsResolver $optionsResolver, array $optio
9393
$this->writeData($data, $options);
9494
}
9595

96-
private function writeData(array $data, array $options)
96+
private function writeData(array $data, array $options): void
9797
{
9898
$flags = $options['json_encoding'] ?? 0;
9999

100100
$this->output->write(json_encode($data, $flags | \JSON_PRETTY_PRINT)."\n");
101101
}
102102

103-
private function sortOptions(array &$options)
103+
private function sortOptions(array &$options): void
104104
{
105105
foreach ($options as &$opts) {
106106
$sorted = false;

Console/Descriptor/TextDescriptor.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function __construct(FileLinkFormatter $fileLinkFormatter = null)
3131
$this->fileLinkFormatter = $fileLinkFormatter;
3232
}
3333

34-
protected function describeDefaults(array $options)
34+
protected function describeDefaults(array $options): void
3535
{
3636
if ($options['core_types']) {
3737
$this->output->section('Built-in form types (Symfony\Component\Form\Extension\Core\Type)');
@@ -59,7 +59,7 @@ protected function describeDefaults(array $options)
5959
}
6060
}
6161

62-
protected function describeResolvedFormType(ResolvedFormTypeInterface $resolvedFormType, array $options = [])
62+
protected function describeResolvedFormType(ResolvedFormTypeInterface $resolvedFormType, array $options = []): void
6363
{
6464
$this->collectOptions($resolvedFormType);
6565

@@ -99,7 +99,7 @@ protected function describeResolvedFormType(ResolvedFormTypeInterface $resolvedF
9999
}
100100
}
101101

102-
protected function describeOption(OptionsResolver $optionsResolver, array $options)
102+
protected function describeOption(OptionsResolver $optionsResolver, array $options): void
103103
{
104104
$definition = $this->getOptionDefinition($optionsResolver, $options['option']);
105105

Extension/Core/Type/ChoiceType.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ private function addSubForm(FormBuilderInterface $builder, string $name, ChoiceV
420420
$builder->add($name, $choiceType, $choiceOpts);
421421
}
422422

423-
private function createChoiceList(array $options)
423+
private function createChoiceList(array $options): ChoiceListInterface
424424
{
425425
if (null !== $options['choice_loader']) {
426426
return $this->choiceListFactory->createListFromLoader(
@@ -440,7 +440,7 @@ private function createChoiceList(array $options)
440440
);
441441
}
442442

443-
private function createChoiceListView(ChoiceListInterface $choiceList, array $options)
443+
private function createChoiceListView(ChoiceListInterface $choiceList, array $options): ChoiceListView
444444
{
445445
return $this->choiceListFactory->createView(
446446
$choiceList,

Extension/Core/Type/DateType.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ public function getBlockPrefix(): string
319319
return 'date';
320320
}
321321

322-
private function formatTimestamps(\IntlDateFormatter $formatter, string $regex, array $timestamps)
322+
private function formatTimestamps(\IntlDateFormatter $formatter, string $regex, array $timestamps): array
323323
{
324324
$pattern = $formatter->getPattern();
325325
$timezone = $formatter->getTimeZoneId();
@@ -344,7 +344,7 @@ private function formatTimestamps(\IntlDateFormatter $formatter, string $regex,
344344
return $formattedTimestamps;
345345
}
346346

347-
private function listYears(array $years)
347+
private function listYears(array $years): array
348348
{
349349
$result = [];
350350

@@ -355,7 +355,7 @@ private function listYears(array $years)
355355
return $result;
356356
}
357357

358-
private function listMonths(array $months)
358+
private function listMonths(array $months): array
359359
{
360360
$result = [];
361361

@@ -366,7 +366,7 @@ private function listMonths(array $months)
366366
return $result;
367367
}
368368

369-
private function listDays(array $days)
369+
private function listDays(array $days): array
370370
{
371371
$result = [];
372372

Extension/Core/Type/FileType.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public function getBlockPrefix(): string
124124
return 'file';
125125
}
126126

127-
private function getFileUploadError(int $errorCode)
127+
private function getFileUploadError(int $errorCode): FileUploadError
128128
{
129129
$messageParameters = [];
130130

@@ -191,7 +191,7 @@ private static function getMaxFilesize(): int|float
191191
*
192192
* This method should be kept in sync with Symfony\Component\Validator\Constraints\FileValidator::factorizeSizes().
193193
*/
194-
private function factorizeSizes(int $size, int|float $limit)
194+
private function factorizeSizes(int $size, int|float $limit): array
195195
{
196196
$coef = self::MIB_BYTES;
197197
$coefFactor = self::KIB_BYTES;

0 commit comments

Comments
 (0)