Skip to content

IBX-9727: Added type-hints and adapted codebase to PHP8+ for Behat-related code #1674

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,038 changes: 69 additions & 969 deletions phpstan-baseline.neon

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ services:

Ibexa\AdminUi\Behat\BrowserContext\SystemInfoContext: ~

Ibexa\AdminUi\Behat\BrowserContext\AdministrationContext: ~

Ibexa\AdminUi\Behat\BrowserContext\DashboardContext: ~

Ibexa\AdminUi\Behat\BrowserContext\ContentActionsMenuContext: ~
Expand Down
12 changes: 6 additions & 6 deletions src/lib/Autosave/AutosaveService.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@

final class AutosaveService implements AutosaveServiceInterface
{
private UserSettingService $userSettingService;

private bool $inProgress = false;

public function __construct(UserSettingService $userSettingService)
{
$this->userSettingService = $userSettingService;
public function __construct(
private readonly UserSettingService $userSettingService
) {
}

public function isEnabled(): bool
{
return $this->userSettingService->getUserSetting(Autosave::IDENTIFIER)->value === Autosave::ENABLED_OPTION;
return $this->userSettingService->getUserSetting(
Autosave::IDENTIFIER
)->value === Autosave::ENABLED_OPTION;
}

/**
Expand Down
10 changes: 4 additions & 6 deletions src/lib/Behat/BrowserContext/AdminUpdateContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,11 @@
use Behat\Gherkin\Node\TableNode;
use Ibexa\AdminUi\Behat\Page\AdminUpdateItemPage;

class AdminUpdateContext implements Context
final readonly class AdminUpdateContext implements Context
{
private AdminUpdateItemPage $adminUpdateItemPage;

public function __construct(AdminUpdateItemPage $adminUpdateItemPage)
{
$this->adminUpdateItemPage = $adminUpdateItemPage;
public function __construct(
private AdminUpdateItemPage $adminUpdateItemPage
) {
}

/**
Expand Down
15 changes: 6 additions & 9 deletions src/lib/Behat/BrowserContext/BookmarkContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);

namespace Ibexa\AdminUi\Behat\BrowserContext;

Expand All @@ -12,16 +13,12 @@
use Ibexa\AdminUi\Behat\Page\ContentViewPage;
use PHPUnit\Framework\Assert;

class BookmarkContext implements Context
final readonly class BookmarkContext implements Context
{
private ContentViewPage $contentViewPage;

private BookmarksPage $bookmarksPage;

public function __construct(ContentViewPage $contentViewPage, BookmarksPage $bookmarksPage)
{
$this->contentViewPage = $contentViewPage;
$this->bookmarksPage = $bookmarksPage;
public function __construct(
private ContentViewPage $contentViewPage,
private BookmarksPage $bookmarksPage
) {
}

/**
Expand Down
7 changes: 2 additions & 5 deletions src/lib/Behat/BrowserContext/ContentActionsMenuContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,10 @@
use Ibexa\AdminUi\Behat\Component\ContentActionsMenu;
use PHPUnit\Framework\Assert;

class ContentActionsMenuContext implements Context
final readonly class ContentActionsMenuContext implements Context
{
private ContentActionsMenu $contentActionsMenu;

public function __construct(ContentActionsMenu $contentActionsMenu)
public function __construct(private ContentActionsMenu $contentActionsMenu)
{
$this->contentActionsMenu = $contentActionsMenu;
}

/**
Expand Down
7 changes: 2 additions & 5 deletions src/lib/Behat/BrowserContext/ContentPreviewContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,10 @@
use Behat\Behat\Context\Context;
use Ibexa\AdminUi\Behat\Page\ContentPreviewPage;

class ContentPreviewContext implements Context
final readonly class ContentPreviewContext implements Context
{
private ContentPreviewPage $contentPreviewPage;

public function __construct(ContentPreviewPage $contentPreviewPage)
public function __construct(private ContentPreviewPage $contentPreviewPage)
{
$this->contentPreviewPage = $contentPreviewPage;
}

/**
Expand Down
28 changes: 8 additions & 20 deletions src/lib/Behat/BrowserContext/ContentTypeContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,14 @@
use Ibexa\AdminUi\Behat\Page\ContentTypeUpdatePage;
use PHPUnit\Framework\Assert;

class ContentTypeContext implements Context
final readonly class ContentTypeContext implements Context
{
private ContentTypePage $contentTypePage;

private ContentTypeUpdatePage $contentTypeUpdatePage;

private ContentTypeGroupPage $contentTypeGroupPage;

private ContentTypeGroupsPage $contentTypeGroupsPage;

public function __construct(
ContentTypePage $contentTypePage,
ContentTypeUpdatePage $contentTypeUpdatePage,
ContentTypeGroupPage $contentTypeGroupPage,
ContentTypeGroupsPage $contentTypeGroupsPage
private ContentTypePage $contentTypePage,
private ContentTypeUpdatePage $contentTypeUpdatePage,
private ContentTypeGroupPage $contentTypeGroupPage,
private ContentTypeGroupsPage $contentTypeGroupsPage
) {
$this->contentTypePage = $contentTypePage;
$this->contentTypeUpdatePage = $contentTypeUpdatePage;
$this->contentTypeGroupPage = $contentTypeGroupPage;
$this->contentTypeGroupsPage = $contentTypeGroupsPage;
}

/**
Expand Down Expand Up @@ -79,7 +67,7 @@ public function contentTypeHasProperFields(TableNode $table): void
/**
* @Given there's no :contentTypeName on content types list
*/
public function thereSNoOnContentTypesList($contentTypeName): void
public function thereSNoOnContentTypesList(string $contentTypeName): void
{
Assert::assertFalse($this->contentTypeGroupPage->isContentTypeOnTheList($contentTypeName));
}
Expand All @@ -103,7 +91,7 @@ public function thereSAOnContentTypesGroupList(string $contentTypeGroupName): vo
/**
* @Given there's a :contentTypeName on content types list
*/
public function thereAContentTypeOnContentTypesList($contentTypeName): void
public function thereAContentTypeOnContentTypesList(string $contentTypeName): void
{
Assert::assertTrue($this->contentTypeGroupPage->isContentTypeOnTheList($contentTypeName));
}
Expand Down Expand Up @@ -232,7 +220,7 @@ public function contentTypeGroupCannotBeSelected(string $contentTypeGroupName):
public function iCheckBlockInField(string $blockName): void
{
$this->contentTypeUpdatePage->verifyIsLoaded();
$this->contentTypeUpdatePage->expandLastFieldDefinition('fieldDefinitionOpenContainerEdit');
$this->contentTypeUpdatePage->expandLastFieldDefinition();
$this->contentTypeUpdatePage->expandDefaultBlocksOption();
$this->contentTypeUpdatePage->selectBlock($blockName);
}
Expand Down
19 changes: 10 additions & 9 deletions src/lib/Behat/BrowserContext/ContentUpdateContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,12 @@
use Ibexa\AdminUi\Behat\Page\UserUpdatePage;
use PHPUnit\Framework\Assert;

class ContentUpdateContext implements Context
final readonly class ContentUpdateContext implements Context
{
private ContentUpdateItemPage $contentUpdateItemPage;

private UserUpdatePage $userUpdatePage;

public function __construct(ContentUpdateItemPage $contentUpdateItemPage, UserUpdatePage $userUpdatePage)
{
$this->contentUpdateItemPage = $contentUpdateItemPage;
$this->userUpdatePage = $userUpdatePage;
public function __construct(
private ContentUpdateItemPage $contentUpdateItemPage,
private UserUpdatePage $userUpdatePage
) {
}

/**
Expand Down Expand Up @@ -85,6 +81,11 @@ public function selectContentFromIARepository(string $contentPath, string $field
$this->contentUpdateItemPage->getField($fieldName)->selectFromRepository($contentPath);
}

/**
* @param array<string, mixed> $parameters
*
* @return array<string, mixed>
*/
private function filterOutNonEmptyValues(array $parameters): array
{
$values = $parameters;
Expand Down
17 changes: 4 additions & 13 deletions src/lib/Behat/BrowserContext/ContentViewContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,13 @@
use Ibexa\Behat\Core\Behat\ArgumentParser;
use PHPUnit\Framework\Assert;

final class ContentViewContext implements Context
final readonly class ContentViewContext implements Context
{
private ArgumentParser $argumentParser;

private ContentViewPage $contentViewPage;

private DraftConflictDialog $draftConflictDialog;

public function __construct(
ArgumentParser $argumentParser,
ContentViewPage $contentViewPage,
DraftConflictDialog $draftConflictDialog
private ArgumentParser $argumentParser,
private ContentViewPage $contentViewPage,
private DraftConflictDialog $draftConflictDialog
) {
$this->argumentParser = $argumentParser;
$this->contentViewPage = $contentViewPage;
$this->draftConflictDialog = $draftConflictDialog;
}

/**
Expand Down
18 changes: 6 additions & 12 deletions src/lib/Behat/BrowserContext/DashboardContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,13 @@
use Ibexa\AdminUi\Behat\Page\DashboardPage;
use PHPUnit\Framework\Assert;

class DashboardContext implements Context
final readonly class DashboardContext implements Context
{
private UpperMenu $upperMenu;

private DashboardPage $dashboardPage;

private ContentUpdateItemPage $contentUpdateItemPage;

public function __construct(UpperMenu $upperMenu, DashboardPage $dashboardPage, ContentUpdateItemPage $contentUpdateItemPage)
{
$this->upperMenu = $upperMenu;
$this->dashboardPage = $dashboardPage;
$this->contentUpdateItemPage = $contentUpdateItemPage;
public function __construct(
private UpperMenu $upperMenu,
private DashboardPage $dashboardPage,
private ContentUpdateItemPage $contentUpdateItemPage
) {
}

/**
Expand Down
20 changes: 10 additions & 10 deletions src/lib/Behat/BrowserContext/LanguageContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,12 @@
use Ibexa\AdminUi\Behat\Page\LanguagesPage;
use PHPUnit\Framework\Assert;

class LanguageContext implements Context
final readonly class LanguageContext implements Context
{
private LanguagesPage $languagesPage;

private LanguagePage $languagePage;

public function __construct(LanguagePage $languagePage, LanguagesPage $languagesPage)
{
$this->languagePage = $languagePage;
$this->languagesPage = $languagesPage;
public function __construct(
private LanguagePage $languagePage,
private LanguagesPage $languagesPage
) {
}

/**
Expand Down Expand Up @@ -77,7 +73,11 @@ public function languageHasProperAttributes(TableNode $languageData): void
$expectedEnabledFlag = $languageData->getHash()[0]['Enabled'];

Assert::assertTrue(
$this->languagePage->hasProperties(['Name' => $expectedName, 'Language code' => $expectedCode, 'Enabled' => $expectedEnabledFlag])
$this->languagePage->hasProperties([
'Name' => $expectedName,
'Language code' => $expectedCode,
'Enabled' => $expectedEnabledFlag,
])
);
}

Expand Down
11 changes: 5 additions & 6 deletions src/lib/Behat/BrowserContext/MyDraftsContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,19 @@
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);

namespace Ibexa\AdminUi\Behat\BrowserContext;

use Behat\Behat\Context\Context;
use Ibexa\AdminUi\Behat\Page\MyDraftsPage;
use PHPUnit\Framework\Assert;

final class MyDraftsContext implements Context
final readonly class MyDraftsContext implements Context
{
private MyDraftsPage $myDraftsPage;

public function __construct(MyDraftsPage $myDraftsPage)
{
$this->myDraftsPage = $myDraftsPage;
public function __construct(
private MyDraftsPage $myDraftsPage
) {
}

/**
Expand Down
37 changes: 8 additions & 29 deletions src/lib/Behat/BrowserContext/NavigationContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,38 +17,17 @@
use Ibexa\Behat\Browser\Page\PageRegistry;
use Ibexa\Behat\Core\Behat\ArgumentParser;

class NavigationContext implements Context
final readonly class NavigationContext implements Context
{
private ArgumentParser $argumentParser;

private PageRegistry $pageRegistry;

private UpperMenu $upperMenu;

private LeftMenu $leftMenu;

private Breadcrumb $breadcrumb;

private ContentViewPage $contentViewPage;

private ContentUpdateItemPage $contentUpdateItemPage;

public function __construct(
ArgumentParser $argumentParser,
UpperMenu $upperMenu,
LeftMenu $leftMenu,
Breadcrumb $breadcrumb,
ContentViewPage $contentViewPage,
PageRegistry $pageRegistry,
ContentUpdateItemPage $contentUpdateItemPage
private ArgumentParser $argumentParser,
private UpperMenu $upperMenu,
private LeftMenu $leftMenu,
private Breadcrumb $breadcrumb,
private ContentViewPage $contentViewPage,
private PageRegistry $pageRegistry,
private ContentUpdateItemPage $contentUpdateItemPage
) {
$this->argumentParser = $argumentParser;
$this->pageRegistry = $pageRegistry;
$this->upperMenu = $upperMenu;
$this->leftMenu = $leftMenu;
$this->breadcrumb = $breadcrumb;
$this->contentViewPage = $contentViewPage;
$this->contentUpdateItemPage = $contentUpdateItemPage;
}

/**
Expand Down
14 changes: 4 additions & 10 deletions src/lib/Behat/BrowserContext/NotificationContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,14 @@

use Behat\Behat\Context\Context;
use Ibexa\AdminUi\Behat\Component\Notification;
use Ibexa\Behat\Core\Behat\ArgumentParser;
use PHPUnit\Framework\Assert;

/** Context for actions on notifications */
class NotificationContext implements Context
final readonly class NotificationContext implements Context
{
private Notification $notification;

private ArgumentParser $argumentParser;

public function __construct(Notification $notification, ArgumentParser $argumentParser)
{
$this->notification = $notification;
$this->argumentParser = $argumentParser;
public function __construct(
private Notification $notification
) {
}

/**
Expand Down
Loading
Loading