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

Skip to content

[Form] Fix return types in form builder #42537

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
16 changes: 12 additions & 4 deletions src/Symfony/Component/Form/ButtonBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -430,10 +430,12 @@ public function setIsEmptyCallback(?callable $isEmptyCallback)

/**
* Unsupported method.
*
* @throws BadMethodCallException
*/
public function getEventDispatcher()
{
return null;
throw new BadMethodCallException('Buttons do not support event dispatching.');
}

/**
Expand Down Expand Up @@ -626,26 +628,32 @@ public function getFormFactory()

/**
* Unsupported method.
*
* @throws BadMethodCallException
*/
public function getAction()
{
return null;
throw new BadMethodCallException('Buttons do not support actions.');
}

/**
* Unsupported method.
*
* @throws BadMethodCallException
*/
public function getMethod()
{
return null;
throw new BadMethodCallException('Buttons do not support methods.');
}

/**
* Unsupported method.
*
* @throws BadMethodCallException
*/
public function getRequestHandler()
{
return null;
throw new BadMethodCallException('Buttons do not support request handlers.');
}

/**
Expand Down
10 changes: 5 additions & 5 deletions src/Symfony/Component/Form/FormConfigBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,7 @@ class FormConfigBuilder implements FormConfigBuilderInterface
*/
private $formFactory;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be made non-nullable, unitialized in 6.0


/**
* @var string|null
*/
private $action;

private $action = '';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be safe and mean the same thing. it's only used in the template where both null and '' are treated the same.

private $method = 'POST';

/**
Expand Down Expand Up @@ -396,6 +392,10 @@ public function getDataLocked()
*/
public function getFormFactory()
{
if (!isset($this->formFactory)) {
throw new BadMethodCallException('The form factory must be set before retrieving it.');
}

return $this->formFactory;
}

Expand Down