1010namespace Nette \Application \UI ;
1111
1212use Nette ;
13- use function array_key_exists , array_slice , func_get_arg , func_get_args , func_num_args , get_debug_type , is_array , link , method_exists , sprintf , trigger_error ;
13+ use function array_key_exists , count , func_get_arg , func_num_args , get_debug_type , is_array , link , method_exists , sprintf , trigger_error ;
1414
1515
1616/**
@@ -292,15 +292,15 @@ public static function formatSignalMethod(string $signal): string
292292 /**
293293 * Generates URL to presenter, action or signal.
294294 * @param string $destination in format "[//] [[[module:]presenter:]action | signal! | this] [#fragment]"
295- * @param array| mixed $args
295+ * @param mixed ... $args
296296 * @throws InvalidLinkException
297297 */
298- public function link (string $ destination , $ args = [] ): string
298+ public function link (string $ destination , ... $ args ): string
299299 {
300300 try {
301- $ args = func_num_args () < 3 && is_array ($ args )
302- ? $ args
303- : array_slice ( func_get_args (), 1 ) ;
301+ $ args = count ( $ args ) === 1 && is_array ($ args[ 0 ] ?? null )
302+ ? $ args[ 0 ]
303+ : $ args ;
304304 return $ this ->getPresenter ()->getLinkGenerator ()->link ($ destination , $ args , $ this , 'link ' );
305305
306306 } catch (InvalidLinkException $ e ) {
@@ -312,29 +312,29 @@ public function link(string $destination, $args = []): string
312312 /**
313313 * Returns destination as Link object.
314314 * @param string $destination in format "[//] [[[module:]presenter:]action | signal! | this] [#fragment]"
315- * @param array| mixed $args
315+ * @param mixed ... $args
316316 */
317- public function lazyLink (string $ destination , $ args = [] ): Link
317+ public function lazyLink (string $ destination , ... $ args ): Link
318318 {
319- $ args = func_num_args () < 3 && is_array ($ args )
320- ? $ args
321- : array_slice ( func_get_args (), 1 ) ;
319+ $ args = count ( $ args ) === 1 && is_array ($ args[ 0 ] ?? null )
320+ ? $ args[ 0 ]
321+ : $ args ;
322322 return new Link ($ this , $ destination , $ args );
323323 }
324324
325325
326326 /**
327327 * Determines whether it links to the current page.
328328 * @param ?string $destination in format "[[[module:]presenter:]action | signal! | this]"
329- * @param array| mixed $args
329+ * @param mixed ... $args
330330 * @throws InvalidLinkException
331331 */
332- public function isLinkCurrent (?string $ destination = null , $ args = [] ): bool
332+ public function isLinkCurrent (?string $ destination = null , ... $ args ): bool
333333 {
334334 if ($ destination !== null ) {
335- $ args = func_num_args () < 3 && is_array ($ args )
336- ? $ args
337- : array_slice ( func_get_args (), 1 ) ;
335+ $ args = count ( $ args ) === 1 && is_array ($ args[ 0 ] ?? null )
336+ ? $ args[ 0 ]
337+ : $ args ;
338338 $ this ->getPresenter ()->getLinkGenerator ()->createRequest ($ this , $ destination , $ args , 'test ' );
339339 }
340340
@@ -345,14 +345,14 @@ public function isLinkCurrent(?string $destination = null, $args = []): bool
345345 /**
346346 * Redirect to another presenter, action or signal.
347347 * @param string $destination in format "[//] [[[module:]presenter:]action | signal! | this] [#fragment]"
348- * @param array| mixed $args
348+ * @param mixed ... $args
349349 * @throws Nette\Application\AbortException
350350 */
351- public function redirect (string $ destination , $ args = [] ): never
351+ public function redirect (string $ destination , ... $ args ): never
352352 {
353- $ args = func_num_args () < 3 && is_array ($ args )
354- ? $ args
355- : array_slice ( func_get_args (), 1 ) ;
353+ $ args = count ( $ args ) === 1 && is_array ($ args[ 0 ] ?? null )
354+ ? $ args[ 0 ]
355+ : $ args ;
356356 $ presenter = $ this ->getPresenter ();
357357 $ presenter ->saveGlobalState ();
358358 $ presenter ->redirectUrl ($ presenter ->getLinkGenerator ()->link ($ destination , $ args , $ this , 'redirect ' ));
@@ -362,14 +362,14 @@ public function redirect(string $destination, $args = []): never
362362 /**
363363 * Permanently redirects to presenter, action or signal.
364364 * @param string $destination in format "[//] [[[module:]presenter:]action | signal! | this] [#fragment]"
365- * @param array| mixed $args
365+ * @param mixed ... $args
366366 * @throws Nette\Application\AbortException
367367 */
368- public function redirectPermanent (string $ destination , $ args = [] ): never
368+ public function redirectPermanent (string $ destination , ... $ args ): never
369369 {
370- $ args = func_num_args () < 3 && is_array ($ args )
371- ? $ args
372- : array_slice ( func_get_args (), 1 ) ;
370+ $ args = count ( $ args ) === 1 && is_array ($ args[ 0 ] ?? null )
371+ ? $ args[ 0 ]
372+ : $ args ;
373373 $ presenter = $ this ->getPresenter ();
374374 $ presenter ->redirectUrl (
375375 $ presenter ->getLinkGenerator ()->link ($ destination , $ args , $ this , 'redirect ' ),
0 commit comments