Skip to content

Commit 1117cc0

Browse files
authored
[CI] Fixed missing closure return types (#1780)
* [CI] Fixed missing closure return types * fixed callable typehint * this can be - null, Location, array, string and prolly int as well, good luck finding that out
1 parent 385e514 commit 1117cc0

File tree

98 files changed

+220
-192
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+220
-192
lines changed

phpstan-baseline.neon

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4392,12 +4392,6 @@ parameters:
43924392
count: 1
43934393
path: src/lib/EventListener/ContentProxyCreateDraftListener.php
43944394

4395-
-
4396-
message: '#^Method Ibexa\\AdminUi\\EventListener\\ContentProxyCreateDraftListener\:\:getTranslatedContentFields\(\) return type has no value type specified in iterable type array\.$#'
4397-
identifier: missingType.iterableValue
4398-
count: 1
4399-
path: src/lib/EventListener/ContentProxyCreateDraftListener.php
4400-
44014395
-
44024396
message: '#^Method Ibexa\\AdminUi\\EventListener\\ContentTranslateViewFilterParametersListener\:\:getSubscribedEvents\(\) return type has no value type specified in iterable type array\.$#'
44034397
identifier: missingType.iterableValue
@@ -10398,6 +10392,11 @@ parameters:
1039810392
count: 1
1039910393
path: src/lib/Form/Type/UniversalDiscoveryWidget/UniversalDiscoveryWidgetType.php
1040010394

10395+
-
10396+
message: '#^Closure is missing a return type declaration$#'
10397+
count: 1
10398+
path: src/lib/Form/Type/UniversalDiscoveryWidget/UniversalDiscoveryWidgetType.php
10399+
1040110400
-
1040210401
message: '#^Method Ibexa\\AdminUi\\Form\\Type\\UniversalDiscoveryWidget\\UniversalDiscoveryWidgetType\:\:buildForm\(\) has no return type specified\.$#'
1040310402
identifier: missingType.return
@@ -12942,6 +12941,11 @@ parameters:
1294212941
count: 1
1294312942
path: src/lib/UI/Dataset/LocationsDataset.php
1294412943

12944+
-
12945+
message: '#^Closure is missing a return type declaration$#'
12946+
count: 1
12947+
path: src/lib/UI/Dataset/ObjectStatesDataset.php
12948+
1294512949
-
1294612950
message: '#^Parameter \#2 \$array of function array_map expects array, iterable\<Ibexa\\Contracts\\Core\\Repository\\Values\\ObjectState\\ObjectStateGroup\> given\.$#'
1294712951
identifier: argument.type
@@ -13194,12 +13198,6 @@ parameters:
1319413198
count: 1
1319513199
path: src/lib/UI/Module/Subitems/ValueObjectVisitor/SubitemsRow.php
1319613200

13197-
-
13198-
message: '#^Method Ibexa\\AdminUi\\UI\\Service\\PathService\:\:loadPathLocations\(\) should return array\<Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Location\> but returns array\<Ibexa\\Contracts\\Core\\Repository\\Values\\ValueObject\>\.$#'
13199-
identifier: return.type
13200-
count: 1
13201-
path: src/lib/UI/Service/PathService.php
13202-
1320313201
-
1320413202
message: '#^Method Ibexa\\AdminUi\\UI\\Service\\TabService\:\:getTabsFromGroup\(\) return type has no value type specified in iterable type array\.$#'
1320513203
identifier: missingType.iterableValue

src/bundle/Command/CompileAssetsCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
9898
sprintf('Evaluating command <comment>%s</comment>', $yarnEncoreCommand)
9999
));
100100

101-
$process->run(static function ($type, $buffer) use ($output, $debugFormatter, $process) {
101+
$process->run(static function ($type, $buffer) use ($output, $debugFormatter, $process): void {
102102
$output->write(
103103
$debugFormatter->progress(
104104
spl_object_hash($process),

src/bundle/Controller/BookmarkController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Ibexa\Contracts\Core\Repository\LocationService;
2020
use Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface;
2121
use Pagerfanta\Pagerfanta;
22+
use Symfony\Component\HttpFoundation\RedirectResponse;
2223
use Symfony\Component\HttpFoundation\Request;
2324
use Symfony\Component\HttpFoundation\Response;
2425

@@ -105,7 +106,7 @@ public function removeAction(Request $request): Response
105106
$form->handleRequest($request);
106107

107108
if ($form->isSubmitted()) {
108-
$result = $this->submitHandler->handle($form, function (BookmarkRemoveData $data) {
109+
$result = $this->submitHandler->handle($form, function (BookmarkRemoveData $data): RedirectResponse {
109110
foreach ($data->getBookmarks() as $locationId => $selected) {
110111
$this->bookmarkService->deleteBookmark(
111112
$this->locationService->loadLocation($locationId)

src/bundle/Controller/ContentController.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ public function createAction(Request $request): Response
164164
$form->handleRequest($request);
165165

166166
if ($form->isSubmitted()) {
167-
$result = $this->submitHandler->handle($form, function (ContentCreateData $data) {
167+
$result = $this->submitHandler->handle($form, function (ContentCreateData $data): RedirectResponse {
168168
$contentType = $data->getContentType();
169169
$language = $data->getLanguage();
170170
$parentLocation = $data->getParentLocation();
@@ -242,7 +242,7 @@ public function editAction(Request $request): Response
242242
$form->handleRequest($request);
243243

244244
if ($form->isSubmitted()) {
245-
$result = $this->submitHandler->handle($form, function (ContentEditData $data) {
245+
$result = $this->submitHandler->handle($form, function (ContentEditData $data): Response {
246246
$contentInfo = $data->getContentInfo();
247247
$language = $data->getLanguage();
248248
$location = $data->getLocation();
@@ -269,7 +269,10 @@ public function editAction(Request $request): Response
269269
);
270270

271271
if ($event->hasResponse()) {
272-
return $event->getResponse();
272+
$response = $event->getResponse();
273+
if ($response !== null) {
274+
return $response;
275+
}
273276
}
274277

275278
if (!$versionInfo->isDraft()) {
@@ -331,7 +334,7 @@ public function updateMainLocationAction(Request $request): Response
331334
$form->handleRequest($request);
332335

333336
if ($form->isSubmitted()) {
334-
$result = $this->submitHandler->handle($form, function (ContentMainLocationUpdateData $data) {
337+
$result = $this->submitHandler->handle($form, function (ContentMainLocationUpdateData $data): RedirectResponse {
335338
$contentInfo = $data->getContentInfo();
336339

337340
$contentMetadataUpdateStruct = $this->contentMainLocationUpdateMapper->reverseMap($data);
@@ -467,7 +470,7 @@ public function updateMainTranslationAction(Request $request): Response
467470
$form->handleRequest($request);
468471

469472
if ($form->isSubmitted()) {
470-
$result = $this->submitHandler->handle($form, function (MainTranslationUpdateData $data) {
473+
$result = $this->submitHandler->handle($form, function (MainTranslationUpdateData $data): RedirectResponse {
471474
$content = $data->getContent();
472475
$contentInfo = $content->contentInfo;
473476
$mapper = new MainTranslationUpdateMapper();
@@ -517,7 +520,7 @@ public function updateVisibilityAction(Request $request): Response
517520
$result = null;
518521

519522
if ($form->isSubmitted()) {
520-
$result = $this->submitHandler->handle($form, function (ContentVisibilityUpdateData $data) {
523+
$result = $this->submitHandler->handle($form, function (ContentVisibilityUpdateData $data): RedirectResponse {
521524
$contentInfo = $data->getContentInfo();
522525
$contentName = $this->translationHelper->getTranslatedContentNameByContentInfo($contentInfo);
523526
$desiredVisibility = $data->getVisible();

src/bundle/Controller/ContentDraftController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Ibexa\Contracts\Core\Repository\ContentService;
1919
use Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface;
2020
use Pagerfanta\Pagerfanta;
21+
use Symfony\Component\HttpFoundation\RedirectResponse;
2122
use Symfony\Component\HttpFoundation\Request;
2223
use Symfony\Component\HttpFoundation\Response;
2324

@@ -90,7 +91,7 @@ public function removeAction(Request $request): Response
9091
$form->handleRequest($request);
9192

9293
if ($form->isSubmitted()) {
93-
$result = $this->submitHandler->handle($form, function (ContentRemoveData $data) {
94+
$result = $this->submitHandler->handle($form, function (ContentRemoveData $data): RedirectResponse {
9495
foreach (array_keys($data->getVersions()) as $version) {
9596
$versionId = VersionId::fromString($version);
9697

src/bundle/Controller/ContentTypeController.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public function listAction(ContentTypeGroup $group, string $routeName, int $page
134134
$deletableTypes = [];
135135
$contentTypes = $this->contentTypeService->loadContentTypes($group, $this->configResolver->getParameter('languages'));
136136

137-
usort($contentTypes, static function (ContentType $contentType1, ContentType $contentType2) {
137+
usort($contentTypes, static function (ContentType $contentType1, ContentType $contentType2): int {
138138
return strnatcasecmp($contentType1->getName(), $contentType2->getName());
139139
});
140140

@@ -232,7 +232,7 @@ public function addTranslationAction(Request $request): Response
232232
$contentTypeGroup = $data->getContentTypeGroup();
233233

234234
if ($form->isSubmitted()) {
235-
$result = $this->submitHandler->handle($form, function (TranslationAddData $data) {
235+
$result = $this->submitHandler->handle($form, function (TranslationAddData $data): RedirectResponse {
236236
$contentType = $data->getContentType();
237237
$language = $data->getLanguage();
238238
$baseLanguage = $data->getBaseLanguage();
@@ -288,7 +288,7 @@ public function removeTranslationAction(Request $request): Response
288288
$contentTypeGroup = $data->getContentTypeGroup();
289289

290290
if ($form->isSubmitted()) {
291-
$result = $this->submitHandler->handle($form, function (TranslationRemoveData $data) {
291+
$result = $this->submitHandler->handle($form, function (TranslationRemoveData $data): RedirectResponse {
292292
$contentType = $data->getContentType();
293293
$languageCodes = $data->getLanguageCodes();
294294
$contentTypeGroup = $data->getContentTypeGroup();
@@ -370,7 +370,7 @@ public function editAction(Request $request, ContentTypeGroup $group, ContentTyp
370370

371371
$form->handleRequest($request);
372372
if ($form->isSubmitted()) {
373-
$result = $this->submitHandler->handle($form, function (ContentTypeEditData $data) use ($contentTypeDraft) {
373+
$result = $this->submitHandler->handle($form, function (ContentTypeEditData $data) use ($contentTypeDraft): RedirectResponse {
374374
$contentTypeGroup = $data->getContentTypeGroup();
375375
$language = $data->getLanguage();
376376

@@ -408,7 +408,7 @@ public function copyAction(Request $request, ContentTypeGroup $group, ContentTyp
408408
$form->handleRequest($request);
409409

410410
if ($form->isSubmitted()) {
411-
$result = $this->submitHandler->handle($form, function (ContentTypeCopyData $data) use ($contentTypeService, $notificationHandler) {
411+
$result = $this->submitHandler->handle($form, function (ContentTypeCopyData $data) use ($contentTypeService, $notificationHandler): RedirectResponse {
412412
$contentType = $data->getContentType();
413413

414414
try {
@@ -470,7 +470,7 @@ public function updateAction(
470470
$contentTypeDraft,
471471
$language,
472472
$baseLanguage
473-
) {
473+
): Response {
474474
$action = $form->getClickedButton() ? $form->getClickedButton()->getName() : self::PRIMARY_UPDATE_ACTION;
475475
$this->contentTypeActionDispatcher->dispatchFormAction(
476476
$form,
@@ -575,7 +575,7 @@ public function deleteAction(Request $request, ContentTypeGroup $group, ContentT
575575
$form->handleRequest($request);
576576

577577
if ($form->isSubmitted()) {
578-
$result = $this->submitHandler->handle($form, function () use ($contentType) {
578+
$result = $this->submitHandler->handle($form, function () use ($contentType): void {
579579
$this->contentTypeService->deleteContentType($contentType);
580580

581581
$this->notificationHandler->success(
@@ -612,7 +612,7 @@ public function bulkDeleteAction(Request $request, ContentTypeGroup $group): Res
612612
$form->handleRequest($request);
613613

614614
if ($form->isSubmitted()) {
615-
$result = $this->submitHandler->handle($form, function (ContentTypesDeleteData $data) {
615+
$result = $this->submitHandler->handle($form, function (ContentTypesDeleteData $data): void {
616616
foreach ($data->getContentTypes() as $contentTypeId => $selected) {
617617
$contentType = $this->contentTypeService->loadContentType($contentTypeId);
618618

src/bundle/Controller/ContentTypeGroupController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ public function deleteAction(Request $request, ContentTypeGroup $group): Respons
223223
$form->handleRequest($request);
224224

225225
if ($form->isSubmitted()) {
226-
$result = $this->submitHandler->handle($form, function (ContentTypeGroupDeleteData $data) {
226+
$result = $this->submitHandler->handle($form, function (ContentTypeGroupDeleteData $data): void {
227227
$group = $data->getContentTypeGroup();
228228
$this->contentTypeService->deleteContentTypeGroup($group);
229229

@@ -259,7 +259,7 @@ public function bulkDeleteAction(Request $request): Response
259259
$form->handleRequest($request);
260260

261261
if ($form->isSubmitted()) {
262-
$result = $this->submitHandler->handle($form, function (ContentTypeGroupsDeleteData $data) {
262+
$result = $this->submitHandler->handle($form, function (ContentTypeGroupsDeleteData $data): void {
263263
foreach ($data->getContentTypeGroups() as $contentTypeGroupId => $selected) {
264264
$group = $this->contentTypeService->loadContentTypeGroup($contentTypeGroupId);
265265
$this->contentTypeService->deleteContentTypeGroup($group);

src/bundle/Controller/LanguageController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public function deleteAction(Request $request, Language $language): Response
134134
$form->handleRequest($request);
135135

136136
if ($form->isSubmitted()) {
137-
$result = $this->submitHandler->handle($form, function (LanguageDeleteData $data) {
137+
$result = $this->submitHandler->handle($form, function (LanguageDeleteData $data): void {
138138
$language = $data->getLanguage();
139139
$this->languageService->deleteLanguage($language);
140140

@@ -176,7 +176,7 @@ public function bulkDeleteAction(Request $request): Response
176176
$form->handleRequest($request);
177177

178178
if ($form->isSubmitted()) {
179-
$result = $this->submitHandler->handle($form, function (LanguagesDeleteData $data) {
179+
$result = $this->submitHandler->handle($form, function (LanguagesDeleteData $data): void {
180180
foreach ($data->getLanguages() as $languageId => $selected) {
181181
$language = $this->languageService->loadLanguageById($languageId);
182182
$this->languageService->deleteLanguage($language);

src/bundle/Controller/LocationController.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public function moveAction(Request $request): Response
140140
$location = $form->getData()->getLocation();
141141

142142
if ($form->isSubmitted()) {
143-
$result = $this->submitHandler->handle($form, function (LocationMoveData $data) {
143+
$result = $this->submitHandler->handle($form, function (LocationMoveData $data): RedirectResponse {
144144
$location = $data->getLocation();
145145
$newParentLocation = $data->getNewParentLocation();
146146

@@ -193,7 +193,7 @@ public function copyAction(Request $request): Response
193193
$location = $form->getData()->getLocation();
194194

195195
if ($form->isSubmitted()) {
196-
$result = $this->submitHandler->handle($form, function (LocationCopyData $data) {
196+
$result = $this->submitHandler->handle($form, function (LocationCopyData $data): RedirectResponse {
197197
$location = $data->getLocation();
198198
$newParentLocation = $data->getNewParentLocation();
199199

@@ -259,7 +259,7 @@ public function copySubtreeAction(Request $request): Response
259259
$location = $form->getData()->getLocation();
260260

261261
if ($form->isSubmitted()) {
262-
$result = $this->submitHandler->handle($form, function (LocationCopySubtreeData $data) use ($location) {
262+
$result = $this->submitHandler->handle($form, function (LocationCopySubtreeData $data) use ($location): RedirectResponse {
263263
$newParentLocation = $data->getNewParentLocation();
264264

265265
$copiedContent = $this->locationService->copySubtree(
@@ -305,7 +305,7 @@ public function swapAction(Request $request): Response
305305
$location = $form->getData()->getCurrentLocation();
306306

307307
if ($form->isSubmitted()) {
308-
$result = $this->submitHandler->handle($form, function (LocationSwapData $data) {
308+
$result = $this->submitHandler->handle($form, function (LocationSwapData $data): RedirectResponse {
309309
$currentLocation = $data->getCurrentLocation();
310310
$newLocation = $data->getNewLocation();
311311

@@ -360,7 +360,7 @@ public function trashAction(Request $request): Response
360360
$form->handleRequest($request);
361361

362362
if ($form->isSubmitted()) {
363-
$result = $this->submitHandler->handle($form, function (LocationTrashData $data) {
363+
$result = $this->submitHandler->handle($form, function (LocationTrashData $data): RedirectResponse {
364364
return $this->handleTrashLocation($data);
365365
});
366366

@@ -445,7 +445,7 @@ public function removeAction(Request $request): Response
445445
$contentInfo = $form->getData()->getContentInfo();
446446

447447
if ($form->isSubmitted()) {
448-
$result = $this->submitHandler->handle($form, function (ContentLocationRemoveData $data) {
448+
$result = $this->submitHandler->handle($form, function (ContentLocationRemoveData $data): RedirectResponse {
449449
$contentInfo = $data->getContentInfo();
450450

451451
foreach ($data->getLocations() as $locationId => $selected) {
@@ -609,7 +609,7 @@ public function updateAction(Request $request): Response
609609
$location = $form->getData()->getLocation();
610610

611611
if ($form->isSubmitted()) {
612-
$result = $this->submitHandler->handle($form, function (LocationUpdateData $data) {
612+
$result = $this->submitHandler->handle($form, function (LocationUpdateData $data): RedirectResponse {
613613
$location = $data->getLocation();
614614

615615
$locationUpdateStruct = new LocationUpdateStruct(['sortField' => $data->getSortField(), 'sortOrder' => $data->getSortOrder()]);
@@ -656,7 +656,7 @@ public function assignSectionAction(Request $request): Response
656656
$form->handleRequest($request);
657657

658658
if ($form->isSubmitted()) {
659-
$result = $this->submitHandler->handle($form, function (LocationAssignSubtreeData $data) {
659+
$result = $this->submitHandler->handle($form, function (LocationAssignSubtreeData $data): RedirectResponse {
660660
$section = $data->getSection();
661661
/** @var \Ibexa\Contracts\Core\Repository\Values\Content\Location $location */
662662
$location = $data->getLocation();

0 commit comments

Comments
 (0)