Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: fix rector change on RedirectException #9433

Merged
merged 1 commit into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
20 changes: 13 additions & 7 deletions system/HTTP/Exceptions/RedirectException.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ public function __construct($message = '', int $code = 0, ?Throwable $previous =

if ($message instanceof ResponseInterface) {
$this->response = $message;
$message = '';

$message = '';

if ($this->response->getHeaderLine('Location') === '' && $this->response->getHeaderLine('Refresh') === '') {
throw new LogicException(
Expand All @@ -70,14 +71,19 @@ public function __construct($message = '', int $code = 0, ?Throwable $previous =
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;
}
Expand Down
7 changes: 1 addition & 6 deletions utils/phpstan-baseline/ternary.shortNotAllowed.neon
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# total 38 errors
# total 37 errors

parameters:
ignoreErrors:
Expand Down Expand Up @@ -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
Expand Down
Loading