1616/**
1717 * Container for form controls.
1818 *
19- * @property ArrayHash $values
19+ * @property ArrayHash<mixed> $values
2020 * @property-read \Iterator $controls
21- * @property-read Form|null $form
21+ * @property-read ?Form $form
22+ * @implements \ArrayAccess<string|int, (Control|Container)&Nette\ComponentModel\IComponent>
2223 */
2324class Container extends Nette \ComponentModel \Container implements \ArrayAccess
2425{
@@ -28,12 +29,12 @@ class Container extends Nette\ComponentModel\Container implements \ArrayAccess
2829
2930 /**
3031 * Occurs when the form was validated
31- * @var array<callable(self, array |object): void| callable(array |object): void>
32+ * @var array<callable(self, mixed[] |object): void | callable(mixed[] |object): void>
3233 */
3334 public array $ onValidate = [];
3435 protected ?ControlGroup $ currentGroup = null ;
3536
36- /** @var callable[] extension methods */
37+ /** @var array<string, callable(self): mixed> */
3738 private static array $ extMethods = [];
3839 private ?bool $ validated = false ;
3940 private ?string $ mappedType = null ;
@@ -44,6 +45,7 @@ class Container extends Nette\ComponentModel\Container implements \ArrayAccess
4445
4546 /**
4647 * Fill-in with default values.
48+ * @param mixed[]|object $values
4749 */
4850 public function setDefaults (array |object $ values , bool $ erase = false ): static
4951 {
@@ -55,6 +57,7 @@ public function setDefaults(array|object $values, bool $erase = false): static
5557
5658 /**
5759 * Fill-in with values.
60+ * @param mixed[]|object $values
5861 * @internal
5962 */
6063 public function setValues (array |object $ values , bool $ erase = false , bool $ onlyDisabled = false ): static
@@ -81,7 +84,10 @@ public function setValues(array|object $values, bool $erase = false, bool $onlyD
8184
8285 /**
8386 * Returns the values submitted by the form.
84- * @param Control[]|null $controls
87+ * @template T of object
88+ * @param class-string<T>|T|'array'|true|null $returnType
89+ * @param ?list<Control> $controls
90+ * @return ($returnType is class-string<T>|T ? T : ($returnType is 'array'|true ? mixed[] : ArrayHash<mixed>))
8591 */
8692 public function getValues (string |object |bool |null $ returnType = null , ?array $ controls = null ): object |array
8793 {
@@ -119,7 +125,10 @@ public function getValues(string|object|bool|null $returnType = null, ?array $co
119125
120126 /**
121127 * Returns the potentially unvalidated values submitted by the form.
122- * @param Control[]|null $controls
128+ * @template T of object
129+ * @param class-string<T>|T|'array'|null $returnType
130+ * @param ?list<Control> $controls
131+ * @return ($returnType is class-string<T>|T ? T : ($returnType is 'array' ? mixed[] : ArrayHash<mixed>))
123132 */
124133 public function getUntrustedValues (string |object |null $ returnType = null , ?array $ controls = null ): object |array
125134 {
@@ -177,6 +186,7 @@ public function getUnsafeValues($returnType, ?array $controls = null)
177186 }
178187
179188
189+ /** @param class-string $type */
180190 public function setMappedType (string $ type ): static
181191 {
182192 $ this ->mappedType = $ type ;
@@ -235,6 +245,7 @@ public function validate(?array $controls = null): void
235245
236246 /**
237247 * Returns all validation errors.
248+ * @return list<string|Stringable>
238249 */
239250 public function getErrors (): array
240251 {
@@ -284,6 +295,7 @@ public function addComponent(
284295
285296 /**
286297 * Iterates over all form controls.
298+ * @return iterable<Control>
287299 */
288300 public function getControls (): \Iterator
289301 {
@@ -462,6 +474,7 @@ public function addCheckbox(string $name, string|Stringable|null $caption = null
462474
463475 /**
464476 * Adds set of radio button controls to the form.
477+ * @param ?mixed[] $items
465478 */
466479 public function addRadioList (
467480 string $ name ,
@@ -475,6 +488,7 @@ public function addRadioList(
475488
476489 /**
477490 * Adds set of checkbox controls to the form.
491+ * @param ?mixed[] $items
478492 */
479493 public function addCheckboxList (
480494 string $ name ,
@@ -488,6 +502,7 @@ public function addCheckboxList(
488502
489503 /**
490504 * Adds select box control that allows single item selection.
505+ * @param ?mixed[] $items
491506 */
492507 public function addSelect (
493508 string $ name ,
@@ -503,6 +518,7 @@ public function addSelect(
503518
504519 /**
505520 * Adds select box control that allows multiple item selection.
521+ * @param ?mixed[] $items
506522 */
507523 public function addMultiSelect (
508524 string $ name ,
@@ -576,6 +592,7 @@ public function addContainer(string|int $name): self
576592 /********************* extension methods ****************d*g**/
577593
578594
595+ /** @param mixed[] $args */
579596 public function __call (string $ name , array $ args )
580597 {
581598 if (isset (self ::$ extMethods [$ name ])) {
@@ -586,6 +603,7 @@ public function __call(string $name, array $args)
586603 }
587604
588605
606+ /** @param callable(self): mixed $callback */
589607 public static function extensionMethod (string $ name , /*callable*/ $ callback ): void
590608 {
591609 if (str_contains ($ name , ':: ' )) { // back compatibility
0 commit comments