mirror of
https://github.com/codeigniter4/CodeIgniter4.git
synced 2025-02-20 11:44:28 +08:00
refactor: fix rector change on RedirectException (#9433)
This commit is contained in:
parent
b18a4067f6
commit
b5e9715518
@ -28,7 +28,7 @@
|
||||
"phpunit/phpcov": "^9.0.2 || ^10.0",
|
||||
"phpunit/phpunit": "^10.5.16 || ^11.2",
|
||||
"predis/predis": "^1.1 || ^2.3",
|
||||
"rector/rector": "2.0.6",
|
||||
"rector/rector": "2.0.7",
|
||||
"shipmonk/phpstan-baseline-per-identifier": "^2.0"
|
||||
},
|
||||
"replace": {
|
||||
|
@ -51,7 +51,8 @@ class RedirectException extends RuntimeException implements ExceptionInterface,
|
||||
|
||||
if ($message instanceof ResponseInterface) {
|
||||
$this->response = $message;
|
||||
$message = '';
|
||||
|
||||
$message = '';
|
||||
|
||||
if ($this->response->getHeaderLine('Location') === '' && $this->response->getHeaderLine('Refresh') === '') {
|
||||
throw new LogicException(
|
||||
@ -70,14 +71,19 @@ class RedirectException extends RuntimeException implements ExceptionInterface,
|
||||
public function getResponse(): ResponseInterface
|
||||
{
|
||||
if (! $this->response instanceof ResponseInterface) {
|
||||
$this->response = service('response')
|
||||
->redirect(base_url($this->getMessage()), 'auto', $this->getCode());
|
||||
$this->response = service('response')->redirect(
|
||||
base_url($this->getMessage()),
|
||||
'auto',
|
||||
$this->getCode(),
|
||||
);
|
||||
}
|
||||
|
||||
service('logger')->info(
|
||||
'REDIRECTED ROUTE at '
|
||||
. ($this->response->getHeaderLine('Location') ?: substr($this->response->getHeaderLine('Refresh'), 6)),
|
||||
);
|
||||
$location = $this->response->getHeaderLine('Location');
|
||||
|
||||
service(('logger'))->info(sprintf(
|
||||
'REDIRECTED ROUTE at %s',
|
||||
$location !== '' ? $location : substr($this->response->getHeaderLine('Refresh'), 6),
|
||||
));
|
||||
|
||||
return $this->response;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
# total 38 errors
|
||||
# total 37 errors
|
||||
|
||||
parameters:
|
||||
ignoreErrors:
|
||||
@ -47,11 +47,6 @@ parameters:
|
||||
count: 1
|
||||
path: ../../system/HTTP/CURLRequest.php
|
||||
|
||||
-
|
||||
message: '#^Short ternary operator is not allowed\. Use null coalesce operator if applicable or consider using long ternary\.$#'
|
||||
count: 1
|
||||
path: ../../system/HTTP/Exceptions/RedirectException.php
|
||||
|
||||
-
|
||||
message: '#^Short ternary operator is not allowed\. Use null coalesce operator if applicable or consider using long ternary\.$#'
|
||||
count: 2
|
||||
|
Loading…
x
Reference in New Issue
Block a user