Skip to content

Commit ed0642b

Browse files
committed
[Form] Fix return types in form builder
1 parent 2ca6078 commit ed0642b

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

ButtonBuilder.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -430,10 +430,12 @@ public function setIsEmptyCallback(?callable $isEmptyCallback)
430430

431431
/**
432432
* Unsupported method.
433+
*
434+
* @throws BadMethodCallException
433435
*/
434436
public function getEventDispatcher()
435437
{
436-
return null;
438+
throw new BadMethodCallException('Buttons do not support event dispatching.');
437439
}
438440

439441
/**
@@ -626,26 +628,32 @@ public function getFormFactory()
626628

627629
/**
628630
* Unsupported method.
631+
*
632+
* @throws BadMethodCallException
629633
*/
630634
public function getAction()
631635
{
632-
return null;
636+
throw new BadMethodCallException('Buttons do not support actions.');
633637
}
634638

635639
/**
636640
* Unsupported method.
641+
*
642+
* @throws BadMethodCallException
637643
*/
638644
public function getMethod()
639645
{
640-
return null;
646+
throw new BadMethodCallException('Buttons do not support methods.');
641647
}
642648

643649
/**
644650
* Unsupported method.
651+
*
652+
* @throws BadMethodCallException
645653
*/
646654
public function getRequestHandler()
647655
{
648-
return null;
656+
throw new BadMethodCallException('Buttons do not support request handlers.');
649657
}
650658

651659
/**

FormConfigBuilder.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,7 @@ class FormConfigBuilder implements FormConfigBuilderInterface
8888
*/
8989
private $formFactory;
9090

91-
/**
92-
* @var string|null
93-
*/
94-
private $action;
95-
91+
private $action = '';
9692
private $method = 'POST';
9793

9894
/**
@@ -396,6 +392,10 @@ public function getDataLocked()
396392
*/
397393
public function getFormFactory()
398394
{
395+
if (!isset($this->formFactory)) {
396+
throw new BadMethodCallException('The form factory must be set before retrieving it.');
397+
}
398+
399399
return $this->formFactory;
400400
}
401401

0 commit comments

Comments
 (0)