Skip to content

Commit

Permalink
Merge a56a185 into eca6d54
Browse files Browse the repository at this point in the history
  • Loading branch information
ADmad committed Oct 9, 2020
2 parents eca6d54 + a56a185 commit 62ff02b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
5 changes: 0 additions & 5 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,3 @@ parameters:
message: "#^Strict comparison using \\!\\=\\= between null and null will always evaluate to false\\.$#"
count: 2
path: src/Command/I18nExtractCommand.php

-
message: "#^Parameter \\#1 \\$request of method ADmad\\\\I18n\\\\Middleware\\\\I18nMiddleware\\:\\:detectLanguage\\(\\) expects Cake\\\\Http\\\\ServerRequest, Psr\\\\Http\\\\Message\\\\ServerRequestInterface given\\.$#"
count: 1
path: src/Middleware/I18nMiddleware.php
6 changes: 3 additions & 3 deletions src/Middleware/I18nMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,13 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
}

$config = $this->getConfig();
$url = $request->getUri()->getPath();

if ($url === '/') {
/** @var \Cake\Http\ServerRequest $request */
if ($request->getPath() === '/') {
$statusCode = 301;
$lang = $config['defaultLanguage'];
if ($config['detectLanguage']) {
$statusCode = 302;
/** @psalm-suppress ArgumentTypeCoercion */
$lang = $this->detectLanguage($request, $lang);
}

Expand Down Expand Up @@ -159,6 +158,7 @@ public function detectLanguage(ServerRequest $request, ?string $default = null)
array_keys($this->_config['languages'])
);
if (!empty($acceptedLangs)) {
/** @var string $lang */
$lang = reset($acceptedLangs);
}

Expand Down

0 comments on commit 62ff02b

Please sign in to comment.