diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index eb551a95..853be2fb 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -240,11 +240,6 @@ parameters: count: 1 path: src/Form.php - - - message: "#^Parameter \\#1 \\$attributes of method ipl\\\\Html\\\\Contract\\\\FormElement\\:\\:addAttributes\\(\\) expects iterable, mixed given\\.$#" - count: 1 - path: src/Form.php - - message: "#^Parameter \\#1 \\.\\.\\.\\$arrays of function array_merge_recursive expects array, array\\|object\\|null given\\.$#" count: 1 @@ -362,11 +357,6 @@ parameters: - message: "#^Cannot access offset 'name' on mixed\\.$#" - count: 2 - path: src/FormElement/BaseFormElement.php - - - - message: "#^Method ipl\\\\Html\\\\FormElement\\\\BaseFormElement\\:\\:addValidators\\(\\) has parameter \\$validators with no value type specified in iterable type iterable\\.$#" count: 1 path: src/FormElement/BaseFormElement.php @@ -395,11 +385,6 @@ parameters: count: 1 path: src/FormElement/BaseFormElement.php - - - message: "#^Method ipl\\\\Html\\\\FormElement\\\\BaseFormElement\\:\\:setValidators\\(\\) has parameter \\$validators with no value type specified in iterable type iterable\\.$#" - count: 1 - path: src/FormElement/BaseFormElement.php - - message: "#^Parameter \\#1 \\$attributes of method ipl\\\\Html\\\\BaseHtmlElement\\:\\:addAttributes\\(\\) expects array\\|ipl\\\\Html\\\\Attributes, mixed given\\.$#" count: 1 @@ -435,11 +420,6 @@ parameters: count: 1 path: src/FormElement/FieldsetElement.php - - - message: "#^Parameter \\#1 \\$attributes of method ipl\\\\Html\\\\Contract\\\\FormElement\\:\\:addAttributes\\(\\) expects iterable, mixed given\\.$#" - count: 1 - path: src/FormElement/FieldsetElement.php - - message: "#^Parameter \\#3 \\$postfix of method ipl\\\\Html\\\\FormElement\\\\FieldsetElement\\:\\:addPluginLoader\\(\\) expects string, string\\|null given\\.$#" count: 2 diff --git a/src/FormElement/BaseFormElement.php b/src/FormElement/BaseFormElement.php index 837ac45b..36edd470 100644 --- a/src/FormElement/BaseFormElement.php +++ b/src/FormElement/BaseFormElement.php @@ -12,6 +12,7 @@ use ipl\Stdlib\Messages; use ipl\Validator\ValidatorChain; use ReflectionProperty; +use Traversable; abstract class BaseFormElement extends BaseHtmlElement implements FormElement, ValueCandidates { @@ -184,7 +185,7 @@ public function getValidators() /** * Set the validators * - * @param iterable $validators + * @param Traversable $validators * * @return $this */ @@ -201,7 +202,7 @@ public function setValidators($validators) /** * Add validators * - * @param iterable $validators + * @param Traversable $validators * * @return $this */ diff --git a/src/FormElement/FormElements.php b/src/FormElement/FormElements.php index 4a2c5986..f413338c 100644 --- a/src/FormElement/FormElements.php +++ b/src/FormElement/FormElements.php @@ -3,6 +3,7 @@ namespace ipl\Html\FormElement; use InvalidArgumentException; +use ipl\Html\BaseHtmlElement; use ipl\Html\Contract\FormElement; use ipl\Html\Contract\FormElementDecorator; use ipl\Html\Contract\ValueCandidates; @@ -29,7 +30,7 @@ trait FormElements /** @var bool Whether the default element loader has been registered */ protected $defaultElementLoaderRegistered = false; - /** @var FormElement[] */ + /** @var (FormElement & BaseHtmlElement)[] */ private $elements = []; /** @var array> */ @@ -38,7 +39,7 @@ trait FormElements /** * Get all elements * - * @return FormElement[] + * @return (FormElement & BaseHtmlElement)[] */ public function getElements() { @@ -70,7 +71,7 @@ public function hasElement($element) * * @param string $name * - * @return FormElement + * @return FormElement & BaseHtmlElement * * @throws InvalidArgumentException If no element with the given name exists */ @@ -89,9 +90,9 @@ public function getElement($name) /** * Add an element * - * @param string|FormElement $typeOrElement Type of the element as string or an instance of FormElement - * @param string $name Name of the element - * @param mixed $options Element options as key-value pairs + * @param string|(FormElement & BaseHtmlElement) $typeOrElement Element name OR FormElement instance + * @param string $name Name of the element + * @param array|null $options Element options as key-value pairs * * @return $this * @@ -135,9 +136,9 @@ public function addElement($typeOrElement, $name = null, $options = null) * * @param string $type Type of the element * @param string $name Name of the element - * @param mixed $options Element options as key-value pairs + * @param array|null $options Element options as key-value pairs * - * @return FormElement + * @return FormElement & BaseHtmlElement * * @throws InvalidArgumentException If the type of the element is unknown */ @@ -154,7 +155,7 @@ public function createElement($type, $name, $options = null) )); } - /** @var FormElement $element */ + /** @var FormElement & BaseFormElement $element */ $element = new $class($name); if ($options !== null) { @@ -169,7 +170,7 @@ public function createElement($type, $name, $options = null) * * Registers the element for value and validation handling but does not add it to the render stack. * - * @param FormElement $element + * @param FormElement & BaseHtmlElement $element * * @return $this *