Skip to content

Commit e91dc66

Browse files
committed
refactor: fix rector change on RedirectException
1 parent 909e9b0 commit e91dc66

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

system/HTTP/Exceptions/RedirectException.php

+13-7
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ public function __construct($message = '', int $code = 0, ?Throwable $previous =
5151

5252
if ($message instanceof ResponseInterface) {
5353
$this->response = $message;
54-
$message = '';
54+
55+
$message = '';
5556

5657
if ($this->response->getHeaderLine('Location') === '' && $this->response->getHeaderLine('Refresh') === '') {
5758
throw new LogicException(
@@ -70,14 +71,19 @@ public function __construct($message = '', int $code = 0, ?Throwable $previous =
7071
public function getResponse(): ResponseInterface
7172
{
7273
if (! $this->response instanceof ResponseInterface) {
73-
$this->response = service('response')
74-
->redirect(base_url($this->getMessage()), 'auto', $this->getCode());
74+
$this->response = service('response')->redirect(
75+
base_url($this->getMessage()),
76+
'auto',
77+
$this->getCode(),
78+
);
7579
}
7680

77-
service('logger')->info(
78-
'REDIRECTED ROUTE at '
79-
. ($this->response->getHeaderLine('Location') ?: substr($this->response->getHeaderLine('Refresh'), 6)),
80-
);
81+
$location = $this->response->getHeaderLine('Location');
82+
83+
service(('logger'))->info(sprintf(
84+
'REDIRECTED ROUTE at %s',
85+
$location !== '' ? $location : substr($this->response->getHeaderLine('Refresh'), 6),
86+
));
8187

8288
return $this->response;
8389
}

utils/phpstan-baseline/ternary.shortNotAllowed.neon

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# total 27 errors
1+
# total 37 errors
22

33
parameters:
44
ignoreErrors:
@@ -47,11 +47,6 @@ parameters:
4747
count: 1
4848
path: ../../system/HTTP/CURLRequest.php
4949

50-
-
51-
message: '#^Short ternary operator is not allowed\. Use null coalesce operator if applicable or consider using long ternary\.$#'
52-
count: 1
53-
path: ../../system/HTTP/Exceptions/RedirectException.php
54-
5550
-
5651
message: '#^Short ternary operator is not allowed\. Use null coalesce operator if applicable or consider using long ternary\.$#'
5752
count: 2

0 commit comments

Comments
 (0)