Skip to content

Commit 859941a

Browse files
authored
Added cast to int when trying to load a location in Location redirect controller (#200)
For more details see #200 Key changes: * Added cast to `int` when trying to load a location in Location redirect controller * [PHPStan] Removed resolved issue from the baseline
1 parent 0e12227 commit 859941a

File tree

2 files changed

+2
-8
lines changed

2 files changed

+2
-8
lines changed

phpstan-baseline.neon

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1692,12 +1692,6 @@ parameters:
16921692
count: 3
16931693
path: src/lib/Server/Controller/Location.php
16941694

1695-
-
1696-
message: '#^Parameter \#1 \$locationId of method Ibexa\\Contracts\\Core\\Repository\\LocationService\:\:loadLocation\(\) expects int, string\|null given\.$#'
1697-
identifier: argument.type
1698-
count: 1
1699-
path: src/lib/Server/Controller/Location.php
1700-
17011695
-
17021696
message: '#^Parameter \#1 \$remoteId of method Ibexa\\Contracts\\Core\\Repository\\LocationService\:\:loadLocationByRemoteId\(\) expects string, string\|null given\.$#'
17031697
identifier: argument.type

src/lib/Server/Controller/Location.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,12 @@ public function __construct(
8383
public function redirectLocation(Request $request)
8484
{
8585
if ($request->query->has('id')) {
86-
$location = $this->locationService->loadLocation($request->query->get('id'));
86+
$location = $this->locationService->loadLocation($request->query->getInt('id'));
8787
} elseif ($request->query->has('remoteId')) {
8888
$location = $this->locationService->loadLocationByRemoteId($request->query->get('remoteId'));
8989
} elseif ($request->query->has('urlAlias')) {
9090
$urlAlias = $this->urlAliasService->lookup($request->query->get('urlAlias'));
91-
$location = $this->locationService->loadLocation($urlAlias->destination);
91+
$location = $this->locationService->loadLocation((int)$urlAlias->destination);
9292
} else {
9393
throw new BadRequestException("At least one of 'id', 'remoteId' or 'urlAlias' parameters is required.");
9494
}

0 commit comments

Comments
 (0)