1111
1212use Nette ;
1313use Nette \Utils \ArrayHash ;
14+ use Stringable ;
1415
1516
1617/**
@@ -275,22 +276,24 @@ public function getForm(bool $throw = true): ?Form
275276
276277 /**
277278 * Adds single-line text input control to the form.
278- * @param string|object $label
279279 */
280- public function addText (string $ name , $ label = null , int $ cols = null , int $ maxLength = null ): Controls \TextInput
281- {
280+ public function addText (
281+ string $ name ,
282+ string |Stringable $ label = null ,
283+ int $ cols = null ,
284+ int $ maxLength = null ,
285+ ): Controls \TextInput {
282286 return $ this [$ name ] = (new Controls \TextInput ($ label , $ maxLength ))
283287 ->setHtmlAttribute ('size ' , $ cols );
284288 }
285289
286290
287291 /**
288292 * Adds single-line text input control used for sensitive input such as passwords.
289- * @param string|object $label
290293 */
291294 public function addPassword (
292295 string $ name ,
293- $ label = null ,
296+ string | Stringable $ label = null ,
294297 int $ cols = null ,
295298 int $ maxLength = null ,
296299 ): Controls \TextInput {
@@ -302,20 +305,22 @@ public function addPassword(
302305
303306 /**
304307 * Adds multi-line text input control to the form.
305- * @param string|object $label
306308 */
307- public function addTextArea (string $ name , $ label = null , int $ cols = null , int $ rows = null ): Controls \TextArea
308- {
309+ public function addTextArea (
310+ string $ name ,
311+ string |Stringable $ label = null ,
312+ int $ cols = null ,
313+ int $ rows = null ,
314+ ): Controls \TextArea {
309315 return $ this [$ name ] = (new Controls \TextArea ($ label ))
310316 ->setHtmlAttribute ('cols ' , $ cols )->setHtmlAttribute ('rows ' , $ rows );
311317 }
312318
313319
314320 /**
315321 * Adds input for email.
316- * @param string|object $label
317322 */
318- public function addEmail (string $ name , $ label = null ): Controls \TextInput
323+ public function addEmail (string $ name , string | Stringable $ label = null ): Controls \TextInput
319324 {
320325 return $ this [$ name ] = (new Controls \TextInput ($ label ))
321326 ->addRule (Form::EMAIL );
@@ -324,9 +329,8 @@ public function addEmail(string $name, $label = null): Controls\TextInput
324329
325330 /**
326331 * Adds input for integer.
327- * @param string|object $label
328332 */
329- public function addInteger (string $ name , $ label = null ): Controls \TextInput
333+ public function addInteger (string $ name , string | Stringable $ label = null ): Controls \TextInput
330334 {
331335 return $ this [$ name ] = (new Controls \TextInput ($ label ))
332336 ->setNullable ()
@@ -336,19 +340,17 @@ public function addInteger(string $name, $label = null): Controls\TextInput
336340
337341 /**
338342 * Adds control that allows the user to upload files.
339- * @param string|object $label
340343 */
341- public function addUpload (string $ name , $ label = null ): Controls \UploadControl
344+ public function addUpload (string $ name , string | Stringable $ label = null ): Controls \UploadControl
342345 {
343346 return $ this [$ name ] = new Controls \UploadControl ($ label , false );
344347 }
345348
346349
347350 /**
348351 * Adds control that allows the user to upload multiple files.
349- * @param string|object $label
350352 */
351- public function addMultiUpload (string $ name , $ label = null ): Controls \UploadControl
353+ public function addMultiUpload (string $ name , string | Stringable $ label = null ): Controls \UploadControl
352354 {
353355 return $ this [$ name ] = new Controls \UploadControl ($ label , true );
354356 }
@@ -366,52 +368,54 @@ public function addHidden(string $name, $default = null): Controls\HiddenField
366368
367369 /**
368370 * Adds check box control to the form.
369- * @param string|object $caption
370371 */
371- public function addCheckbox (string $ name , $ caption = null ): Controls \Checkbox
372+ public function addCheckbox (string $ name , string | Stringable $ caption = null ): Controls \Checkbox
372373 {
373374 return $ this [$ name ] = new Controls \Checkbox ($ caption );
374375 }
375376
376377
377378 /**
378379 * Adds set of radio button controls to the form.
379- * @param string|object $label
380380 */
381- public function addRadioList (string $ name , $ label = null , array $ items = null ): Controls \RadioList
381+ public function addRadioList (string $ name , string | Stringable $ label = null , array $ items = null ): Controls \RadioList
382382 {
383383 return $ this [$ name ] = new Controls \RadioList ($ label , $ items );
384384 }
385385
386386
387387 /**
388388 * Adds set of checkbox controls to the form.
389- * @param string|object $label
390389 */
391- public function addCheckboxList (string $ name , $ label = null , array $ items = null ): Controls \CheckboxList
392- {
390+ public function addCheckboxList (
391+ string $ name ,
392+ string |Stringable $ label = null ,
393+ array $ items = null ,
394+ ): Controls \CheckboxList {
393395 return $ this [$ name ] = new Controls \CheckboxList ($ label , $ items );
394396 }
395397
396398
397399 /**
398400 * Adds select box control that allows single item selection.
399- * @param string|object $label
400401 */
401- public function addSelect (string $ name , $ label = null , array $ items = null , int $ size = null ): Controls \SelectBox
402- {
402+ public function addSelect (
403+ string $ name ,
404+ string |Stringable $ label = null ,
405+ array $ items = null ,
406+ int $ size = null ,
407+ ): Controls \SelectBox {
403408 return $ this [$ name ] = (new Controls \SelectBox ($ label , $ items ))
404409 ->setHtmlAttribute ('size ' , $ size > 1 ? $ size : null );
405410 }
406411
407412
408413 /**
409414 * Adds select box control that allows multiple item selection.
410- * @param string|object $label
411415 */
412416 public function addMultiSelect (
413417 string $ name ,
414- $ label = null ,
418+ string | Stringable $ label = null ,
415419 array $ items = null ,
416420 int $ size = null
417421 ): Controls \MultiSelectBox {
@@ -422,19 +426,17 @@ public function addMultiSelect(
422426
423427 /**
424428 * Adds button used to submit form.
425- * @param string|object $caption
426429 */
427- public function addSubmit (string $ name , $ caption = null ): Controls \SubmitButton
430+ public function addSubmit (string $ name , string | Stringable $ caption = null ): Controls \SubmitButton
428431 {
429432 return $ this [$ name ] = new Controls \SubmitButton ($ caption );
430433 }
431434
432435
433436 /**
434437 * Adds push buttons with no default behavior.
435- * @param string|object $caption
436438 */
437- public function addButton (string $ name , $ caption = null ): Controls \Button
439+ public function addButton (string $ name , string | Stringable $ caption = null ): Controls \Button
438440 {
439441 return $ this [$ name ] = new Controls \Button ($ caption );
440442 }
0 commit comments