Skip to content

Commit

Permalink
Component::redirect() removed $code from signature [Closes #220][Closes
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Jul 7, 2019
1 parent d1378d4 commit 24ead35
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Application/UI/Component.php
Original file line number Diff line number Diff line change
Expand Up @@ -280,17 +280,17 @@ public function isLinkCurrent(string $destination = null, $args = []): bool
* @param array|mixed $args
* @throws Nette\Application\AbortException
*/
public function redirect($code, $destination = null, $args = []): void
public function redirect(/*int $code, string */$destination, $args = []): void

This comment has been minimized.

Copy link
@JanGalek

JanGalek Jul 25, 2019

Contributor

BC break :)

This comment has been minimized.

Copy link
@mabar

mabar Jul 25, 2019

Contributor

@JanGalek It still works same ways as before, doesn't it?

This comment has been minimized.

Copy link
@JanGalek

JanGalek Jul 25, 2019

Contributor

@mabar no, if you have redirect(301, '...', [...]); :) I prefere do it at MINOR :)

This comment has been minimized.

Copy link
@dg

dg Jul 25, 2019

Author Member

Can you add failing test to Component.redirect().phpt, please?

This comment has been minimized.

Copy link
@mabar

mabar Jul 25, 2019

Contributor

So it fails to an exception with a code given?
Change breaking only static analysis tools is totally ok for patch version because it was a bug.
And deprecation is here for more than 2 years and since nette 2.4 29602ef

This comment has been minimized.

This comment has been minimized.

Copy link
@JanGalek

JanGalek Jul 25, 2019

Contributor

@mabar oh, ok sorry for confuse.

{
if (is_numeric($code)) {
if (is_numeric($destination)) {
trigger_error(__METHOD__ . '() first parameter $code is deprecated; use redirectPermanent() for 301 redirect.', E_USER_DEPRECATED);
[$code, $destination, $args] = func_get_args() + [null, null, []];
if (func_num_args() > 3 || !is_array($args)) {
$args = array_slice(func_get_args(), 2);
}
} elseif (!is_numeric($code)) { // first parameter is optional
$args = func_num_args() < 3 && is_array($destination) ? $destination : array_slice(func_get_args(), 1);
$destination = $code;
} else {
$code = null;
$args = func_num_args() < 3 && is_array($args) ? $args : array_slice(func_get_args(), 1);
}

$presenter = $this->getPresenter();
Expand Down

0 comments on commit 24ead35

Please sign in to comment.