Skip to content

Commit 0dd28e0

Browse files
committed
IBX-9727: Added type-hints and adapted codebase to PHP8+ for Behat-related code
1 parent 7c931cf commit 0dd28e0

File tree

107 files changed

+1084
-1892
lines changed

Some content is hidden

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

107 files changed

+1084
-1892
lines changed

phpstan-baseline.neon

Lines changed: 69 additions & 969 deletions
Large diffs are not rendered by default.

src/bundle/Resources/config/services/test/feature_contexts.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ services:
1212

1313
Ibexa\AdminUi\Behat\BrowserContext\SystemInfoContext: ~
1414

15-
Ibexa\AdminUi\Behat\BrowserContext\AdministrationContext: ~
16-
1715
Ibexa\AdminUi\Behat\BrowserContext\DashboardContext: ~
1816

1917
Ibexa\AdminUi\Behat\BrowserContext\ContentActionsMenuContext: ~

src/lib/Autosave/AutosaveService.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@
1515

1616
final class AutosaveService implements AutosaveServiceInterface
1717
{
18-
private UserSettingService $userSettingService;
19-
2018
private bool $inProgress = false;
2119

22-
public function __construct(UserSettingService $userSettingService)
23-
{
24-
$this->userSettingService = $userSettingService;
20+
public function __construct(
21+
private readonly UserSettingService $userSettingService
22+
) {
2523
}
2624

2725
public function isEnabled(): bool
2826
{
29-
return $this->userSettingService->getUserSetting(Autosave::IDENTIFIER)->value === Autosave::ENABLED_OPTION;
27+
return $this->userSettingService->getUserSetting(
28+
Autosave::IDENTIFIER
29+
)->value === Autosave::ENABLED_OPTION;
3030
}
3131

3232
/**

src/lib/Behat/BrowserContext/AdminUpdateContext.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,11 @@
1212
use Behat\Gherkin\Node\TableNode;
1313
use Ibexa\AdminUi\Behat\Page\AdminUpdateItemPage;
1414

15-
class AdminUpdateContext implements Context
15+
final readonly class AdminUpdateContext implements Context
1616
{
17-
private AdminUpdateItemPage $adminUpdateItemPage;
18-
19-
public function __construct(AdminUpdateItemPage $adminUpdateItemPage)
20-
{
21-
$this->adminUpdateItemPage = $adminUpdateItemPage;
17+
public function __construct(
18+
private AdminUpdateItemPage $adminUpdateItemPage
19+
) {
2220
}
2321

2422
/**

src/lib/Behat/BrowserContext/BookmarkContext.php

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* @copyright Copyright (C) Ibexa AS. All rights reserved.
55
* @license For full copyright and license information view LICENSE file distributed with this source code.
66
*/
7+
declare(strict_types=1);
78

89
namespace Ibexa\AdminUi\Behat\BrowserContext;
910

@@ -12,16 +13,12 @@
1213
use Ibexa\AdminUi\Behat\Page\ContentViewPage;
1314
use PHPUnit\Framework\Assert;
1415

15-
class BookmarkContext implements Context
16+
final readonly class BookmarkContext implements Context
1617
{
17-
private ContentViewPage $contentViewPage;
18-
19-
private BookmarksPage $bookmarksPage;
20-
21-
public function __construct(ContentViewPage $contentViewPage, BookmarksPage $bookmarksPage)
22-
{
23-
$this->contentViewPage = $contentViewPage;
24-
$this->bookmarksPage = $bookmarksPage;
18+
public function __construct(
19+
private ContentViewPage $contentViewPage,
20+
private BookmarksPage $bookmarksPage
21+
) {
2522
}
2623

2724
/**

src/lib/Behat/BrowserContext/ContentActionsMenuContext.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,10 @@
1313
use Ibexa\AdminUi\Behat\Component\ContentActionsMenu;
1414
use PHPUnit\Framework\Assert;
1515

16-
class ContentActionsMenuContext implements Context
16+
final readonly class ContentActionsMenuContext implements Context
1717
{
18-
private ContentActionsMenu $contentActionsMenu;
19-
20-
public function __construct(ContentActionsMenu $contentActionsMenu)
18+
public function __construct(private ContentActionsMenu $contentActionsMenu)
2119
{
22-
$this->contentActionsMenu = $contentActionsMenu;
2320
}
2421

2522
/**

src/lib/Behat/BrowserContext/ContentPreviewContext.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,10 @@
1111
use Behat\Behat\Context\Context;
1212
use Ibexa\AdminUi\Behat\Page\ContentPreviewPage;
1313

14-
class ContentPreviewContext implements Context
14+
final readonly class ContentPreviewContext implements Context
1515
{
16-
private ContentPreviewPage $contentPreviewPage;
17-
18-
public function __construct(ContentPreviewPage $contentPreviewPage)
16+
public function __construct(private ContentPreviewPage $contentPreviewPage)
1917
{
20-
$this->contentPreviewPage = $contentPreviewPage;
2118
}
2219

2320
/**

src/lib/Behat/BrowserContext/ContentTypeContext.php

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,14 @@
1616
use Ibexa\AdminUi\Behat\Page\ContentTypeUpdatePage;
1717
use PHPUnit\Framework\Assert;
1818

19-
class ContentTypeContext implements Context
19+
final readonly class ContentTypeContext implements Context
2020
{
21-
private ContentTypePage $contentTypePage;
22-
23-
private ContentTypeUpdatePage $contentTypeUpdatePage;
24-
25-
private ContentTypeGroupPage $contentTypeGroupPage;
26-
27-
private ContentTypeGroupsPage $contentTypeGroupsPage;
28-
2921
public function __construct(
30-
ContentTypePage $contentTypePage,
31-
ContentTypeUpdatePage $contentTypeUpdatePage,
32-
ContentTypeGroupPage $contentTypeGroupPage,
33-
ContentTypeGroupsPage $contentTypeGroupsPage
22+
private ContentTypePage $contentTypePage,
23+
private ContentTypeUpdatePage $contentTypeUpdatePage,
24+
private ContentTypeGroupPage $contentTypeGroupPage,
25+
private ContentTypeGroupsPage $contentTypeGroupsPage
3426
) {
35-
$this->contentTypePage = $contentTypePage;
36-
$this->contentTypeUpdatePage = $contentTypeUpdatePage;
37-
$this->contentTypeGroupPage = $contentTypeGroupPage;
38-
$this->contentTypeGroupsPage = $contentTypeGroupsPage;
3927
}
4028

4129
/**
@@ -79,7 +67,7 @@ public function contentTypeHasProperFields(TableNode $table): void
7967
/**
8068
* @Given there's no :contentTypeName on content types list
8169
*/
82-
public function thereSNoOnContentTypesList($contentTypeName): void
70+
public function thereSNoOnContentTypesList(string $contentTypeName): void
8371
{
8472
Assert::assertFalse($this->contentTypeGroupPage->isContentTypeOnTheList($contentTypeName));
8573
}
@@ -103,7 +91,7 @@ public function thereSAOnContentTypesGroupList(string $contentTypeGroupName): vo
10391
/**
10492
* @Given there's a :contentTypeName on content types list
10593
*/
106-
public function thereAContentTypeOnContentTypesList($contentTypeName): void
94+
public function thereAContentTypeOnContentTypesList(string $contentTypeName): void
10795
{
10896
Assert::assertTrue($this->contentTypeGroupPage->isContentTypeOnTheList($contentTypeName));
10997
}
@@ -129,9 +117,9 @@ public function iAddField(string $fieldName): void
129117
/**
130118
* @When I set :field to :value for :fieldName field
131119
*/
132-
public function iSetFieldDefinitionData(string $label, string $value, string $fieldName): void
120+
public function iSetFieldDefinitionData(string $label, string $value): void
133121
{
134-
$this->contentTypeUpdatePage->fillFieldDefinitionFieldWithValue($fieldName, $label, $value);
122+
$this->contentTypeUpdatePage->fillFieldDefinitionFieldWithValue($label, $value);
135123
}
136124

137125
/**
@@ -232,7 +220,7 @@ public function contentTypeGroupCannotBeSelected(string $contentTypeGroupName):
232220
public function iCheckBlockInField(string $blockName): void
233221
{
234222
$this->contentTypeUpdatePage->verifyIsLoaded();
235-
$this->contentTypeUpdatePage->expandLastFieldDefinition('fieldDefinitionOpenContainerEdit');
223+
$this->contentTypeUpdatePage->expandLastFieldDefinition();
236224
$this->contentTypeUpdatePage->expandDefaultBlocksOption();
237225
$this->contentTypeUpdatePage->selectBlock($blockName);
238226
}

src/lib/Behat/BrowserContext/ContentUpdateContext.php

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,12 @@
1515
use Ibexa\AdminUi\Behat\Page\UserUpdatePage;
1616
use PHPUnit\Framework\Assert;
1717

18-
class ContentUpdateContext implements Context
18+
final readonly class ContentUpdateContext implements Context
1919
{
20-
private ContentUpdateItemPage $contentUpdateItemPage;
21-
22-
private UserUpdatePage $userUpdatePage;
23-
24-
public function __construct(ContentUpdateItemPage $contentUpdateItemPage, UserUpdatePage $userUpdatePage)
25-
{
26-
$this->contentUpdateItemPage = $contentUpdateItemPage;
27-
$this->userUpdatePage = $userUpdatePage;
20+
public function __construct(
21+
private ContentUpdateItemPage $contentUpdateItemPage,
22+
private UserUpdatePage $userUpdatePage
23+
) {
2824
}
2925

3026
/**
@@ -49,7 +45,7 @@ public function fieldContainsValidationError(string $fieldName, string $errorMes
4945
}
5046

5147
/**
52-
* @Given the :fieldName field is noneditable
48+
* @Given the :fieldName field is non-editable
5349
*/
5450
public function verifyFieldIsNotEditable(string $fieldName): void
5551
{
@@ -85,6 +81,11 @@ public function selectContentFromIARepository(string $contentPath, string $field
8581
$this->contentUpdateItemPage->getField($fieldName)->selectFromRepository($contentPath);
8682
}
8783

84+
/**
85+
* @param array<string, mixed> $parameters
86+
*
87+
* @return array<string, mixed>
88+
*/
8889
private function filterOutNonEmptyValues(array $parameters): array
8990
{
9091
$values = $parameters;

src/lib/Behat/BrowserContext/ContentViewContext.php

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,13 @@
1515
use Ibexa\Behat\Core\Behat\ArgumentParser;
1616
use PHPUnit\Framework\Assert;
1717

18-
final class ContentViewContext implements Context
18+
final readonly class ContentViewContext implements Context
1919
{
20-
private ArgumentParser $argumentParser;
21-
22-
private ContentViewPage $contentViewPage;
23-
24-
private DraftConflictDialog $draftConflictDialog;
25-
2620
public function __construct(
27-
ArgumentParser $argumentParser,
28-
ContentViewPage $contentViewPage,
29-
DraftConflictDialog $draftConflictDialog
21+
private ArgumentParser $argumentParser,
22+
private ContentViewPage $contentViewPage,
23+
private DraftConflictDialog $draftConflictDialog
3024
) {
31-
$this->argumentParser = $argumentParser;
32-
$this->contentViewPage = $contentViewPage;
33-
$this->draftConflictDialog = $draftConflictDialog;
3425
}
3526

3627
/**

0 commit comments

Comments
 (0)