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, 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(static, 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(static): 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 * Populates controls with default values. Has no effect on submitted forms.
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 * Fills controls 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|self> $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|self> $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 {
@@ -170,7 +179,11 @@ public function getUntrustedValues(string|object|null $returnType = null, ?array
170179 }
171180
172181
173- /** @deprecated use getUntrustedValues() */
182+ /**
183+ * @param ?list<Control|self> $controls
184+ * @return object|mixed[]
185+ * @deprecated use getUntrustedValues()
186+ */
174187 public function getUnsafeValues ($ returnType , ?array $ controls = null )
175188 {
176189 return $ this ->getUntrustedValues ($ returnType , $ controls );
@@ -179,6 +192,7 @@ public function getUnsafeValues($returnType, ?array $controls = null)
179192
180193 /**
181194 * Sets the default class used when getValues() is called without an explicit type.
195+ * @param class-string $type
182196 */
183197 public function setMappedType (string $ type ): static
184198 {
@@ -238,6 +252,7 @@ public function validate(?array $controls = null): void
238252
239253 /**
240254 * Returns all validation errors.
255+ * @return list<string|Stringable>
241256 */
242257 public function getErrors (): array
243258 {
@@ -287,6 +302,7 @@ public function addComponent(
287302
288303 /**
289304 * Iterates over all form controls.
305+ * @return \Iterator<Control>
290306 */
291307 public function getControls (): \Iterator
292308 {
@@ -465,6 +481,7 @@ public function addCheckbox(string $name, string|Stringable|null $caption = null
465481
466482 /**
467483 * Adds set of radio button controls to the form.
484+ * @param ?mixed[] $items
468485 */
469486 public function addRadioList (
470487 string $ name ,
@@ -478,6 +495,7 @@ public function addRadioList(
478495
479496 /**
480497 * Adds set of checkbox controls to the form.
498+ * @param ?mixed[] $items
481499 */
482500 public function addCheckboxList (
483501 string $ name ,
@@ -491,6 +509,7 @@ public function addCheckboxList(
491509
492510 /**
493511 * Adds select box control that allows single item selection.
512+ * @param ?mixed[] $items
494513 */
495514 public function addSelect (
496515 string $ name ,
@@ -506,6 +525,7 @@ public function addSelect(
506525
507526 /**
508527 * Adds select box control that allows multiple item selection.
528+ * @param ?mixed[] $items
509529 */
510530 public function addMultiSelect (
511531 string $ name ,
@@ -579,6 +599,7 @@ public function addContainer(string|int $name): self
579599 /********************* extension methods ****************d*g**/
580600
581601
602+ /** @param mixed[] $args */
582603 public function __call (string $ name , array $ args )
583604 {
584605 if (isset (self ::$ extMethods [$ name ])) {
@@ -589,6 +610,7 @@ public function __call(string $name, array $args)
589610 }
590611
591612
613+ /** @param callable(static): mixed $callback */
592614 public static function extensionMethod (string $ name , /*callable*/ $ callback ): void
593615 {
594616 if (str_contains ($ name , ':: ' )) { // back compatibility
0 commit comments