diff --git a/src/Symfony/Component/Form/ButtonBuilder.php b/src/Symfony/Component/Form/ButtonBuilder.php index 82ce9af05d0d9..efbd2d10a1cdf 100644 --- a/src/Symfony/Component/Form/ButtonBuilder.php +++ b/src/Symfony/Component/Form/ButtonBuilder.php @@ -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.'); } /** @@ -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.'); } /** diff --git a/src/Symfony/Component/Form/FormConfigBuilder.php b/src/Symfony/Component/Form/FormConfigBuilder.php index 7e7b40edacabb..b511c2f1364fb 100644 --- a/src/Symfony/Component/Form/FormConfigBuilder.php +++ b/src/Symfony/Component/Form/FormConfigBuilder.php @@ -88,11 +88,7 @@ class FormConfigBuilder implements FormConfigBuilderInterface */ private $formFactory; - /** - * @var string|null - */ - private $action; - + private $action = ''; private $method = 'POST'; /** @@ -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; }