Skip to content

Commit c03d915

Browse files
committed
PHPStan
1 parent b74d170 commit c03d915

31 files changed

+210
-122
lines changed

src/bundle/ApiPlatform/Head.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,19 @@
1717
#[\Attribute(\Attribute::TARGET_CLASS | \Attribute::IS_REPEATABLE)]
1818
final class Head extends HttpOperation
1919
{
20+
/**
21+
* @param array<string, mixed>|null $defaults
22+
* @param array<string, mixed>|null $denormalizationContext
23+
* @param array<string, mixed>|null $exceptionToStatus
24+
* @param array<string, mixed> $extraProperties
25+
* @param array<string, mixed>|null $hydraContext
26+
* @param array<string, mixed>|null $mercure
27+
* @param array<string, mixed>|null $normalizationContext
28+
* @param array<string, mixed>|null $options
29+
* @param array<string, mixed>|null $requirements
30+
* @param array<string, mixed>|null $schemes
31+
* @param array<string, mixed>|null $validationContext
32+
*/
2033
public function __construct(
2134
?string $uriTemplate = null,
2235
?array $types = null,

src/lib/Server/Controller/Section/SectionUpdateController.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use ApiPlatform\OpenApi\Model;
1313
use Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException;
1414
use Ibexa\Contracts\Core\Repository\SectionService;
15+
use Ibexa\Contracts\Core\Repository\Values\Content\Section;
1516
use Ibexa\Contracts\Core\Repository\Values\Content\SectionCreateStruct;
1617
use Ibexa\Contracts\Core\Repository\Values\Content\SectionUpdateStruct;
1718
use Ibexa\Rest\Message;
@@ -127,13 +128,9 @@ public function __construct(SectionService $sectionService)
127128
/**
128129
* Updates a section.
129130
*
130-
* @param $sectionId
131-
*
132131
* @throws \Ibexa\Rest\Server\Exceptions\ForbiddenException
133-
*
134-
* @return \Ibexa\Contracts\Core\Repository\Values\Content\Section
135132
*/
136-
public function updateSection($sectionId, Request $request)
133+
public function updateSection(int $sectionId, Request $request): Section
137134
{
138135
$createStruct = $this->inputDispatcher->parse(
139136
new Message(

src/lib/Server/Controller/Session/SessionCheckController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ final class SessionCheckController extends SessionBaseController
7777
public function checkSessionAction(Request $request)
7878
{
7979
$session = $request->getSession();
80-
if ($session === null || !$session->isStarted()) {
80+
if (!$session->isStarted()) {
8181
return $this->logout($request);
8282
}
8383

src/lib/Server/Controller/Session/SessionRefreshController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ final class SessionRefreshController extends SessionBaseController
9696
*
9797
* @deprecated 5.0.0 The "SessionController::refreshSessionAction()" method is deprecated, will be removed in the next API version. Use SessionController::checkSessionAction() instead.
9898
*
99-
* @throws \Ibexa\Core\Base\Exceptions\UnauthorizedException
10099
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException
100+
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException
101101
*/
102102
public function refreshSessionAction(string $sessionId, Request $request): Values\UserSession|Response
103103
{
@@ -109,7 +109,7 @@ public function refreshSessionAction(string $sessionId, Request $request): Value
109109

110110
$session = $request->getSession();
111111

112-
if ($session === null || !$session->isStarted() || $session->getId() !== $sessionId || !$this->hasStoredCsrfToken()) {
112+
if (!$session->isStarted() || $session->getId() !== $sessionId || !$this->hasStoredCsrfToken()) {
113113
return $this->logout($request);
114114
}
115115

src/lib/Server/Controller/Trash/TrashItemDeleteController.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,8 @@ public function __construct(
5656

5757
/**
5858
* Deletes the given trash item.
59-
*
60-
* @param $trashItemId
61-
*
62-
* @return \Ibexa\Rest\Server\Values\NoContent
6359
*/
64-
public function deleteTrashItem($trashItemId)
60+
public function deleteTrashItem(int $trashItemId): Values\NoContent
6561
{
6662
$this->trashService->deleteTrashItem(
6763
$this->trashService->loadTrashItem($trashItemId)

src/lib/Server/Controller/Trash/TrashItemLoadByIdController.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,8 @@ public function __construct(
7878

7979
/**
8080
* Returns the trash item given by id.
81-
*
82-
* @param $trashItemId
83-
*
84-
* @return \Ibexa\Rest\Server\Values\RestTrashItem
8581
*/
86-
public function loadTrashItem($trashItemId)
82+
public function loadTrashItem(int $trashItemId): Values\RestTrashItem
8783
{
8884
return new Values\RestTrashItem(
8985
$trashItem = $this->trashService->loadTrashItem($trashItemId),

src/lib/Server/Controller/Trash/TrashItemRestoreController.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,11 @@ public function __construct(
3030
/**
3131
* Restores a trashItem.
3232
*
33-
* @param $trashItemId
34-
*
35-
* @return \Ibexa\Rest\Server\Values\ResourceCreated
36-
*
37-
* @throws \Ibexa\Rest\Server\Exceptions\ForbiddenException
33+
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException
34+
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException
35+
* @throws \InvalidArgumentException
3836
*/
39-
public function restoreTrashItem($trashItemId, Request $request)
37+
public function restoreTrashItem(int $trashItemId, Request $request): Values\ResourceCreated
4038
{
4139
$requestDestination = null;
4240
try {
@@ -49,11 +47,11 @@ public function restoreTrashItem($trashItemId, Request $request)
4947
if ($request->headers->has('Destination')) {
5048
$locationPathParts = explode(
5149
'/',
52-
$this->requestParser->parseHref($request->headers->get('Destination'), 'locationPath')
50+
$this->uriParser->getAttributeFromUri((string)$request->headers->get('Destination'), 'locationPath')
5351
);
5452

5553
try {
56-
$parentLocation = $this->locationService->loadLocation(array_pop($locationPathParts));
54+
$parentLocation = $this->locationService->loadLocation((int)array_pop($locationPathParts));
5755
} catch (NotFoundException $e) {
5856
throw new ForbiddenException(/** @Ignore */ $e->getMessage());
5957
}

src/lib/Server/Controller/URLAlias/URLAliasCreateController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,11 @@ public function createURLAlias(Request $request)
123123
if ($urlAliasCreate['_type'] === 'LOCATION') {
124124
$locationPathParts = explode(
125125
'/',
126-
$this->requestParser->parseHref($urlAliasCreate['location']['_href'], 'locationPath')
126+
$this->uriParser->getAttributeFromUri($urlAliasCreate['location']['_href'], 'locationPath')
127127
);
128128

129129
$location = $this->locationService->loadLocation(
130-
array_pop($locationPathParts)
130+
(int)array_pop($locationPathParts)
131131
);
132132

133133
try {

src/lib/Server/Controller/URLAlias/URLAliasDeleteController.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,8 @@ public function __construct(
5656

5757
/**
5858
* The given URL alias is deleted.
59-
*
60-
* @param $urlAliasId
61-
*
62-
* @return \Ibexa\Rest\Server\Values\NoContent
6359
*/
64-
public function deleteURLAlias($urlAliasId)
60+
public function deleteURLAlias(string $urlAliasId): Values\NoContent
6561
{
6662
$this->urlAliasService->removeAliases(
6763
[

src/lib/Server/Controller/URLAlias/URLAliasListGlobalController.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,16 @@ public function __construct(
6868

6969
/**
7070
* Returns the list of global URL aliases.
71-
*
72-
* @return \Ibexa\Rest\Server\Values\URLAliasRefList
7371
*/
74-
public function listGlobalURLAliases()
72+
public function listGlobalURLAliases(): Values\URLAliasRefList
7573
{
74+
$globalAliasesArray = [];
75+
foreach ($this->urlAliasService->listGlobalAliases() as $alias) {
76+
$globalAliasesArray[] = $alias;
77+
}
78+
7679
return new Values\URLAliasRefList(
77-
$this->urlAliasService->listGlobalAliases(),
80+
$globalAliasesArray,
7881
$this->router->generate('ibexa.rest.list_global_url_aliases')
7982
);
8083
}

0 commit comments

Comments
 (0)