Skip to content

Commit b5e9715

Browse files
authored
refactor: fix rector change on RedirectException (#9433)
1 parent b18a406 commit b5e9715

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"phpunit/phpcov": "^9.0.2 || ^10.0",
2929
"phpunit/phpunit": "^10.5.16 || ^11.2",
3030
"predis/predis": "^1.1 || ^2.3",
31-
"rector/rector": "2.0.6",
31+
"rector/rector": "2.0.7",
3232
"shipmonk/phpstan-baseline-per-identifier": "^2.0"
3333
},
3434
"replace": {

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 38 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)