Skip to content

Commit

Permalink
Add missing return types
Browse files Browse the repository at this point in the history
  • Loading branch information
wouterj committed Apr 28, 2023
1 parent 8428ce6 commit cb76849
Show file tree
Hide file tree
Showing 8 changed files with 111 additions and 3 deletions.
6 changes: 6 additions & 0 deletions AbstractType.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,17 @@ public function configureOptions(OptionsResolver $resolver)
{
}

/**
* @return string
*/
public function getBlockPrefix()
{
return StringUtil::fqcnToBlockPrefix(static::class) ?: '';
}

/**
* @return string|null
*/
public function getParent()
{
return FormType::class;
Expand Down
64 changes: 64 additions & 0 deletions ButtonBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ public function __construct(?string $name, array $options = [])
/**
* Unsupported method.
*
* @return never
*
* @throws BadMethodCallException
*/
public function add(string|FormBuilderInterface $child, string $type = null, array $options = []): static
Expand All @@ -62,6 +64,8 @@ public function add(string|FormBuilderInterface $child, string $type = null, arr
/**
* Unsupported method.
*
* @return never
*
* @throws BadMethodCallException
*/
public function create(string $name, string $type = null, array $options = []): FormBuilderInterface
Expand All @@ -72,6 +76,8 @@ public function create(string $name, string $type = null, array $options = []):
/**
* Unsupported method.
*
* @return never
*
* @throws BadMethodCallException
*/
public function get(string $name): FormBuilderInterface
Expand All @@ -82,6 +88,8 @@ public function get(string $name): FormBuilderInterface
/**
* Unsupported method.
*
* @return never
*
* @throws BadMethodCallException
*/
public function remove(string $name): static
Expand Down Expand Up @@ -116,6 +124,8 @@ public function getForm(): Button
/**
* Unsupported method.
*
* @return never
*
* @throws BadMethodCallException
*/
public function addEventListener(string $eventName, callable $listener, int $priority = 0): static
Expand All @@ -126,6 +136,8 @@ public function addEventListener(string $eventName, callable $listener, int $pri
/**
* Unsupported method.
*
* @return never
*
* @throws BadMethodCallException
*/
public function addEventSubscriber(EventSubscriberInterface $subscriber): static
Expand All @@ -136,6 +148,8 @@ public function addEventSubscriber(EventSubscriberInterface $subscriber): static
/**
* Unsupported method.
*
* @return never
*
* @throws BadMethodCallException
*/
public function addViewTransformer(DataTransformerInterface $viewTransformer, bool $forcePrepend = false): static
Expand All @@ -146,6 +160,8 @@ public function addViewTransformer(DataTransformerInterface $viewTransformer, bo
/**
* Unsupported method.
*
* @return never
*
* @throws BadMethodCallException
*/
public function resetViewTransformers(): static
Expand All @@ -156,6 +172,8 @@ public function resetViewTransformers(): static
/**
* Unsupported method.
*
* @return never
*
* @throws BadMethodCallException
*/
public function addModelTransformer(DataTransformerInterface $modelTransformer, bool $forceAppend = false): static
Expand All @@ -166,6 +184,8 @@ public function addModelTransformer(DataTransformerInterface $modelTransformer,
/**
* Unsupported method.
*
* @return never
*
* @throws BadMethodCallException
*/
public function resetModelTransformers(): static
Expand Down Expand Up @@ -196,6 +216,8 @@ public function setAttributes(array $attributes): static
/**
* Unsupported method.
*
* @return never
*
* @throws BadMethodCallException
*/
public function setDataMapper(DataMapperInterface $dataMapper = null): static
Expand All @@ -222,6 +244,8 @@ public function setDisabled(bool $disabled): static
/**
* Unsupported method.
*
* @return never
*
* @throws BadMethodCallException
*/
public function setEmptyData(mixed $emptyData): static
Expand All @@ -232,6 +256,8 @@ public function setEmptyData(mixed $emptyData): static
/**
* Unsupported method.
*
* @return never
*
* @throws BadMethodCallException
*/
public function setErrorBubbling(bool $errorBubbling): static
Expand All @@ -242,6 +268,8 @@ public function setErrorBubbling(bool $errorBubbling): static
/**
* Unsupported method.
*
* @return never
*
* @throws BadMethodCallException
*/
public function setRequired(bool $required): static
Expand All @@ -252,6 +280,8 @@ public function setRequired(bool $required): static
/**
* Unsupported method.
*
* @return never
*
* @throws BadMethodCallException
*/
public function setPropertyPath(string|PropertyPathInterface|null $propertyPath): static
Expand All @@ -262,6 +292,8 @@ public function setPropertyPath(string|PropertyPathInterface|null $propertyPath)
/**
* Unsupported method.
*
* @return never
*
* @throws BadMethodCallException
*/
public function setMapped(bool $mapped): static
Expand All @@ -272,6 +304,8 @@ public function setMapped(bool $mapped): static
/**
* Unsupported method.
*
* @return never
*
* @throws BadMethodCallException
*/
public function setByReference(bool $byReference): static
Expand All @@ -282,6 +316,8 @@ public function setByReference(bool $byReference): static
/**
* Unsupported method.
*
* @return never
*
* @throws BadMethodCallException
*/
public function setCompound(bool $compound): static
Expand All @@ -304,6 +340,8 @@ public function setType(ResolvedFormTypeInterface $type): static
/**
* Unsupported method.
*
* @return never
*
* @throws BadMethodCallException
*/
public function setData(mixed $data): static
Expand All @@ -314,6 +352,8 @@ public function setData(mixed $data): static
/**
* Unsupported method.
*
* @return never
*
* @throws BadMethodCallException
*/
public function setDataLocked(bool $locked): static
Expand All @@ -324,6 +364,8 @@ public function setDataLocked(bool $locked): static
/**
* Unsupported method.
*
* @return never
*
* @throws BadMethodCallException
*/
public function setFormFactory(FormFactoryInterface $formFactory)
Expand All @@ -334,6 +376,8 @@ public function setFormFactory(FormFactoryInterface $formFactory)
/**
* Unsupported method.
*
* @return never
*
* @throws BadMethodCallException
*/
public function setAction(string $action): static
Expand All @@ -344,6 +388,8 @@ public function setAction(string $action): static
/**
* Unsupported method.
*
* @return never
*
* @throws BadMethodCallException
*/
public function setMethod(string $method): static
Expand All @@ -354,6 +400,8 @@ public function setMethod(string $method): static
/**
* Unsupported method.
*
* @return never
*
* @throws BadMethodCallException
*/
public function setRequestHandler(RequestHandlerInterface $requestHandler): static
Expand All @@ -380,6 +428,8 @@ public function setAutoInitialize(bool $initialize): static
/**
* Unsupported method.
*
* @return never
*
* @throws BadMethodCallException
*/
public function setInheritData(bool $inheritData): static
Expand All @@ -402,6 +452,8 @@ public function getFormConfig(): FormConfigInterface
/**
* Unsupported method.
*
* @return never
*
* @throws BadMethodCallException
*/
public function setIsEmptyCallback(?callable $isEmptyCallback): static
Expand All @@ -412,6 +464,8 @@ public function setIsEmptyCallback(?callable $isEmptyCallback): static
/**
* Unsupported method.
*
* @return never
*
* @throws BadMethodCallException
*/
public function getEventDispatcher(): EventDispatcherInterface
Expand Down Expand Up @@ -570,6 +624,8 @@ public function getDataLocked(): bool

/**
* Unsupported method.
*
* @return never
*/
public function getFormFactory(): FormFactoryInterface
{
Expand All @@ -579,6 +635,8 @@ public function getFormFactory(): FormFactoryInterface
/**
* Unsupported method.
*
* @return never
*
* @throws BadMethodCallException
*/
public function getAction(): string
Expand All @@ -589,6 +647,8 @@ public function getAction(): string
/**
* Unsupported method.
*
* @return never
*
* @throws BadMethodCallException
*/
public function getMethod(): string
Expand All @@ -599,6 +659,8 @@ public function getMethod(): string
/**
* Unsupported method.
*
* @return never
*
* @throws BadMethodCallException
*/
public function getRequestHandler(): RequestHandlerInterface
Expand Down Expand Up @@ -649,6 +711,8 @@ public function getOption(string $name, mixed $default = null): mixed
/**
* Unsupported method.
*
* @return never
*
* @throws BadMethodCallException
*/
public function getIsEmptyCallback(): ?callable
Expand Down
2 changes: 1 addition & 1 deletion Extension/Core/DataAccessor/PropertyPathAccessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function isWritable(object|array $data, FormInterface $form): bool
return null !== $form->getPropertyPath();
}

private function getPropertyValue(object|array $data, PropertyPathInterface $propertyPath)
private function getPropertyValue(object|array $data, PropertyPathInterface $propertyPath): mixed
{
try {
return $this->propertyAccessor->getValue($data, $propertyPath);
Expand Down
16 changes: 14 additions & 2 deletions Extension/Core/Type/ChoiceType.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ public function __construct(ChoiceListFactoryInterface $choiceListFactory = null
$this->translator = $translator;
}

/**
* @return void
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$unknownValues = [];
Expand Down Expand Up @@ -215,6 +218,9 @@ public function buildForm(FormBuilderInterface $builder, array $options)
}, 256);
}

/**
* @return void
*/
public function buildView(FormView $view, FormInterface $form, array $options)
{
$choiceTranslationDomain = $options['choice_translation_domain'];
Expand Down Expand Up @@ -269,6 +275,9 @@ public function buildView(FormView $view, FormInterface $form, array $options)
}
}

/**
* @return void
*/
public function finishView(FormView $view, FormInterface $form, array $options)
{
if ($options['expanded']) {
Expand All @@ -286,6 +295,9 @@ public function finishView(FormView $view, FormInterface $form, array $options)
}
}

/**
* @return void
*/
public function configureOptions(OptionsResolver $resolver)
{
$emptyData = static function (Options $options) {
Expand Down Expand Up @@ -383,7 +395,7 @@ public function getBlockPrefix(): string
/**
* Adds the sub fields for an expanded choice field.
*/
private function addSubForms(FormBuilderInterface $builder, array $choiceViews, array $options)
private function addSubForms(FormBuilderInterface $builder, array $choiceViews, array $options): void
{
foreach ($choiceViews as $name => $choiceView) {
// Flatten groups
Expand All @@ -401,7 +413,7 @@ private function addSubForms(FormBuilderInterface $builder, array $choiceViews,
}
}

private function addSubForm(FormBuilderInterface $builder, string $name, ChoiceView $choiceView, array $options)
private function addSubForm(FormBuilderInterface $builder, string $name, ChoiceView $choiceView, array $options): void
{
$choiceOpts = [
'value' => $choiceView->value,
Expand Down
Loading

0 comments on commit cb76849

Please sign in to comment.