@@ -47,10 +47,8 @@ class Container extends Nette\ComponentModel\Container implements \ArrayAccess
4747
4848 /**
4949 * Fill-in with default values.
50- * @param array|object $data
51- * @return static
5250 */
53- public function setDefaults ($ data , bool $ erase = false )
51+ public function setDefaults (array | object $ data , bool $ erase = false ): static
5452 {
5553 $ form = $ this ->getForm (false );
5654 if (!$ form || !$ form ->isAnchored () || !$ form ->isSubmitted ()) {
@@ -62,20 +60,15 @@ public function setDefaults($data, bool $erase = false)
6260
6361 /**
6462 * Fill-in with values.
65- * @param array|object $data
66- * @return static
6763 * @internal
6864 */
69- public function setValues ($ data , bool $ erase = false )
65+ public function setValues (array | object $ data , bool $ erase = false ): static
7066 {
7167 if ($ data instanceof \Traversable) {
7268 $ values = iterator_to_array ($ data );
7369
7470 } elseif (is_object ($ data ) || is_array ($ data ) || $ data === null ) {
7571 $ values = (array ) $ data ;
76-
77- } else {
78- throw new Nette \InvalidArgumentException (sprintf ('First parameter must be an array or object, %s given. ' , gettype ($ data )));
7972 }
8073
8174 foreach ($ this ->getComponents () as $ name => $ control ) {
@@ -88,7 +81,7 @@ public function setValues($data, bool $erase = false)
8881 }
8982
9083 } elseif ($ control instanceof self) {
91- if (array_key_exists ( $ name , $ values )) {
84+ if (isset ( $ values[ $ name ] )) {
9285 $ control ->setValues ($ values [$ name ], $ erase );
9386
9487 } elseif ($ erase ) {
@@ -104,9 +97,8 @@ public function setValues($data, bool $erase = false)
10497 * Returns the values submitted by the form.
10598 * @param string|object|null $returnType 'array' for array
10699 * @param Control[]|null $controls
107- * @return object|array
108100 */
109- public function getValues ($ returnType = null , array $ controls = null )
101+ public function getValues (string | object | bool $ returnType = null , array $ controls = null ): object | array
110102 {
111103 $ form = $ this ->getForm (false );
112104 if ($ form && ($ submitter = $ form ->isSubmitted ())) {
@@ -126,9 +118,8 @@ public function getValues($returnType = null, array $controls = null)
126118 * Returns the potentially unvalidated values submitted by the form.
127119 * @param string|object|null $returnType 'array' for array
128120 * @param Control[]|null $controls
129- * @return object|array
130121 */
131- public function getUnsafeValues ($ returnType , array $ controls = null )
122+ public function getUnsafeValues (string | object | null $ returnType , array $ controls = null ): object | array
132123 {
133124 if (is_object ($ returnType )) {
134125 $ obj = $ returnType ;
@@ -163,8 +154,7 @@ public function getUnsafeValues($returnType, array $controls = null)
163154 }
164155
165156
166- /** @return static */
167- public function setMappedType (string $ type )
157+ public function setMappedType (string $ type ): static
168158 {
169159 $ this ->mappedType = $ type ;
170160 return $ this ;
@@ -229,8 +219,7 @@ public function getErrors(): array
229219 /********************* form building ****************d*g**/
230220
231221
232- /** @return static */
233- public function setCurrentGroup (ControlGroup $ group = null )
222+ public function setCurrentGroup (ControlGroup $ group = null ): static
234223 {
235224 $ this ->currentGroup = $ group ;
236225 return $ this ;
@@ -248,11 +237,13 @@ public function getCurrentGroup(): ?ControlGroup
248237
249238 /**
250239 * Adds the specified component to the IContainer.
251- * @return static
252240 * @throws Nette\InvalidStateException
253241 */
254- public function addComponent (Nette \ComponentModel \IComponent $ component , ?string $ name , string $ insertBefore = null )
255- {
242+ public function addComponent (
243+ Nette \ComponentModel \IComponent $ component ,
244+ ?string $ name ,
245+ string $ insertBefore = null ,
246+ ): static {
256247 parent ::addComponent ($ component , $ name , $ insertBefore );
257248 if ($ this ->currentGroup !== null ) {
258249 $ this ->currentGroup ->add ($ component );
@@ -469,9 +460,8 @@ public function addImage(): Controls\ImageButton
469460
470461 /**
471462 * Adds naming container to the form.
472- * @param string|int $name
473463 */
474- public function addContainer ($ name ): self
464+ public function addContainer (string | int $ name ): self
475465 {
476466 $ control = new self ;
477467 $ control ->currentGroup = $ this ->currentGroup ;
0 commit comments