Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add return types - batch 6/n #42511

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,5 @@ public function getXsdValidationBasePath();
*
* @return string The alias
*/
public function getAlias(): string;
public function getAlias();
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

use Symfony\Component\ExpressionLanguage\ExpressionFunction;
use Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface;
use Symfony\Component\ExpressionLanguage\ExpressionPhpFunction;

class TestProvider implements ExpressionFunctionProviderInterface
{
Expand Down
12 changes: 6 additions & 6 deletions src/Symfony/Component/Form/AbstractExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ abstract class AbstractExtension implements FormExtensionInterface
/**
* {@inheritdoc}
*/
public function getType(string $name)
public function getType(string $name): FormTypeInterface
{
if (!isset($this->types)) {
$this->initTypes();
Expand All @@ -62,7 +62,7 @@ public function getType(string $name)
/**
* {@inheritdoc}
*/
public function hasType(string $name)
public function hasType(string $name): bool
{
if (!isset($this->types)) {
$this->initTypes();
Expand All @@ -74,7 +74,7 @@ public function hasType(string $name)
/**
* {@inheritdoc}
*/
public function getTypeExtensions(string $name)
public function getTypeExtensions(string $name): array
{
if (!isset($this->typeExtensions)) {
$this->initTypeExtensions();
Expand All @@ -87,7 +87,7 @@ public function getTypeExtensions(string $name)
/**
* {@inheritdoc}
*/
public function hasTypeExtensions(string $name)
public function hasTypeExtensions(string $name): bool
{
if (!isset($this->typeExtensions)) {
$this->initTypeExtensions();
Expand All @@ -99,7 +99,7 @@ public function hasTypeExtensions(string $name)
/**
* {@inheritdoc}
*/
public function getTypeGuesser()
public function getTypeGuesser(): ?FormTypeGuesserInterface
{
if (!$this->typeGuesserLoaded) {
$this->initTypeGuesser();
Expand All @@ -123,7 +123,7 @@ protected function loadTypes()
*
* @return FormTypeExtensionInterface[]
*/
protected function loadTypeExtensions()
protected function loadTypeExtensions(): array
{
return [];
}
Expand Down
6 changes: 3 additions & 3 deletions src/Symfony/Component/Form/AbstractRendererEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function setTheme(FormView $view, mixed $themes, bool $useDefaultThemes =
/**
* {@inheritdoc}
*/
public function getResourceForBlockName(FormView $view, string $blockName)
public function getResourceForBlockName(FormView $view, string $blockName): mixed
{
$cacheKey = $view->vars[self::CACHE_KEY_VAR];

Expand All @@ -93,7 +93,7 @@ public function getResourceForBlockName(FormView $view, string $blockName)
/**
* {@inheritdoc}
*/
public function getResourceForBlockNameHierarchy(FormView $view, array $blockNameHierarchy, int $hierarchyLevel)
public function getResourceForBlockNameHierarchy(FormView $view, array $blockNameHierarchy, int $hierarchyLevel): mixed
{
$cacheKey = $view->vars[self::CACHE_KEY_VAR];
$blockName = $blockNameHierarchy[$hierarchyLevel];
Expand All @@ -108,7 +108,7 @@ public function getResourceForBlockNameHierarchy(FormView $view, array $blockNam
/**
* {@inheritdoc}
*/
public function getResourceHierarchyLevel(FormView $view, array $blockNameHierarchy, int $hierarchyLevel)
public function getResourceHierarchyLevel(FormView $view, array $blockNameHierarchy, int $hierarchyLevel): int|bool
{
$cacheKey = $view->vars[self::CACHE_KEY_VAR];
$blockName = $blockNameHierarchy[$hierarchyLevel];
Expand Down
64 changes: 32 additions & 32 deletions src/Symfony/Component/Form/Button.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

use Symfony\Component\Form\Exception\AlreadySubmittedException;
use Symfony\Component\Form\Exception\BadMethodCallException;
use Symfony\Component\Form\Exception\TransformationFailedException;
use Symfony\Component\PropertyAccess\PropertyPathInterface;

/**
* A form button.
Expand Down Expand Up @@ -82,7 +84,7 @@ public function offsetUnset(mixed $offset): void
/**
* {@inheritdoc}
*/
public function setParent(FormInterface $parent = null)
public function setParent(FormInterface $parent = null): static
{
if ($this->submitted) {
throw new AlreadySubmittedException('You cannot set the parent of a submitted button.');
Expand All @@ -96,7 +98,7 @@ public function setParent(FormInterface $parent = null)
/**
* {@inheritdoc}
*/
public function getParent()
public function getParent(): ?FormInterface
{
return $this->parent;
}
Expand All @@ -108,7 +110,7 @@ public function getParent()
*
* @throws BadMethodCallException
*/
public function add(string|FormInterface $child, string $type = null, array $options = [])
public function add(string|FormInterface $child, string $type = null, array $options = []): static
{
throw new BadMethodCallException('Buttons cannot have children.');
}
Expand All @@ -120,7 +122,7 @@ public function add(string|FormInterface $child, string $type = null, array $opt
*
* @throws BadMethodCallException
*/
public function get(string $name)
public function get(string $name): FormInterface
{
throw new BadMethodCallException('Buttons cannot have children.');
}
Expand All @@ -130,7 +132,7 @@ public function get(string $name)
*
* @return bool Always returns false
*/
public function has(string $name)
public function has(string $name): bool
{
return false;
}
Expand All @@ -142,23 +144,23 @@ public function has(string $name)
*
* @throws BadMethodCallException
*/
public function remove(string $name)
public function remove(string $name): static
{
throw new BadMethodCallException('Buttons cannot have children.');
}

/**
* {@inheritdoc}
*/
public function all()
public function all(): array
{
return [];
}

/**
* {@inheritdoc}
*/
public function getErrors(bool $deep = false, bool $flatten = true)
public function getErrors(bool $deep = false, bool $flatten = true): FormErrorIterator
{
return new FormErrorIterator($this, []);
}
Expand All @@ -170,7 +172,7 @@ public function getErrors(bool $deep = false, bool $flatten = true)
*
* @return $this
*/
public function setData(mixed $modelData)
public function setData(mixed $modelData): static
{
// no-op, called during initialization of the form tree
return $this;
Expand All @@ -179,23 +181,23 @@ public function setData(mixed $modelData)
/**
* Unsupported method.
*/
public function getData()
public function getData(): mixed
{
return null;
}

/**
* Unsupported method.
*/
public function getNormData()
public function getNormData(): mixed
{
return null;
}

/**
* Unsupported method.
*/
public function getViewData()
public function getViewData(): mixed
{
return null;
}
Expand All @@ -205,17 +207,15 @@ public function getViewData()
*
* @return array Always returns an empty array
*/
public function getExtraData()
public function getExtraData(): array
{
return [];
}

/**
* Returns the button's configuration.
*
* @return FormConfigInterface
*/
public function getConfig()
public function getConfig(): FormConfigInterface
{
return $this->config;
}
Expand All @@ -225,7 +225,7 @@ public function getConfig()
*
* @return bool true if the button was submitted
*/
public function isSubmitted()
public function isSubmitted(): bool
{
return $this->submitted;
}
Expand All @@ -235,15 +235,15 @@ public function isSubmitted()
*
* @return string The name of the button
*/
public function getName()
public function getName(): string
{
return $this->config->getName();
}

/**
* Unsupported method.
*/
public function getPropertyPath()
public function getPropertyPath(): ?PropertyPathInterface
{
return null;
}
Expand All @@ -253,7 +253,7 @@ public function getPropertyPath()
*
* @throws BadMethodCallException
*/
public function addError(FormError $error)
public function addError(FormError $error): static
{
throw new BadMethodCallException('Buttons cannot have errors.');
}
Expand All @@ -263,7 +263,7 @@ public function addError(FormError $error)
*
* @return bool Always returns true
*/
public function isValid()
public function isValid(): bool
{
return true;
}
Expand All @@ -273,15 +273,15 @@ public function isValid()
*
* @return bool Always returns false
*/
public function isRequired()
public function isRequired(): bool
{
return false;
}

/**
* {@inheritdoc}
*/
public function isDisabled()
public function isDisabled(): bool
{
if ($this->parent && $this->parent->isDisabled()) {
return true;
Expand All @@ -295,7 +295,7 @@ public function isDisabled()
*
* @return bool Always returns true
*/
public function isEmpty()
public function isEmpty(): bool
{
return true;
}
Expand All @@ -305,15 +305,15 @@ public function isEmpty()
*
* @return bool Always returns true
*/
public function isSynchronized()
public function isSynchronized(): bool
{
return true;
}

/**
* Unsupported method.
*/
public function getTransformationFailure()
public function getTransformationFailure(): ?TransformationFailedException
{
return null;
}
Expand All @@ -323,7 +323,7 @@ public function getTransformationFailure()
*
* @throws BadMethodCallException
*/
public function initialize()
public function initialize(): static
{
throw new BadMethodCallException('Buttons cannot be initialized. Call initialize() on the root form instead.');
}
Expand All @@ -333,7 +333,7 @@ public function initialize()
*
* @throws BadMethodCallException
*/
public function handleRequest(mixed $request = null)
public function handleRequest(mixed $request = null): static
{
throw new BadMethodCallException('Buttons cannot handle requests. Call handleRequest() on the root form instead.');
}
Expand All @@ -345,7 +345,7 @@ public function handleRequest(mixed $request = null)
*
* @throws Exception\AlreadySubmittedException if the button has already been submitted
*/
public function submit(array|string|null $submittedData, bool $clearMissing = true)
public function submit(array|string|null $submittedData, bool $clearMissing = true): static
{
if ($this->submitted) {
throw new AlreadySubmittedException('A form can only be submitted once.');
Expand All @@ -359,23 +359,23 @@ public function submit(array|string|null $submittedData, bool $clearMissing = tr
/**
* {@inheritdoc}
*/
public function getRoot()
public function getRoot(): FormInterface
{
return $this->parent ? $this->parent->getRoot() : $this;
}

/**
* {@inheritdoc}
*/
public function isRoot()
public function isRoot(): bool
{
return null === $this->parent;
}

/**
* {@inheritdoc}
*/
public function createView(FormView $parent = null)
public function createView(FormView $parent = null): FormView
{
if (null === $parent && $this->parent) {
$parent = $this->parent->createView();
Expand Down
Loading