Skip to content

Commit 20bbb8f

Browse files
committed
IBX-9727: Added type-hints and adapted codebase to PHP8+ within contracts
1 parent 95e6f14 commit 20bbb8f

39 files changed

+224
-631
lines changed

phpstan-baseline.neon

Lines changed: 36 additions & 258 deletions
Large diffs are not rendered by default.

src/contracts/Controller/Controller.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ abstract class Controller extends AbstractController implements RestrictedContro
2121
public function redirectToLocation(Location $location, string $uriFragment = ''): RedirectResponse
2222
{
2323
return $this->redirectToRoute('ibexa.content.view', [
24-
'contentId' => $location->contentId,
25-
'locationId' => $location->id,
24+
'contentId' => $location->getContentId(),
25+
'locationId' => $location->getId(),
2626
'_fragment' => $uriFragment,
2727
]);
2828
}

src/contracts/Event/AutosaveEvents.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,5 @@
1010

1111
final class AutosaveEvents
1212
{
13-
/** @var string */
14-
public const CONTENT_AUTOSAVE = 'content.edit.autosave';
13+
public const string CONTENT_AUTOSAVE = 'content.edit.autosave';
1514
}

src/contracts/Event/ContentEditEvent.php

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,11 @@ final class ContentEditEvent extends Event
2020
{
2121
private ?Response $response = null;
2222

23-
private Content $content;
24-
25-
private VersionInfo $versionInfo;
26-
27-
private string $languageCode;
28-
2923
public function __construct(
30-
Content $content,
31-
VersionInfo $versionInfo,
32-
string $languageCode
24+
private readonly Content $content,
25+
private readonly VersionInfo $versionInfo,
26+
private readonly string $languageCode
3327
) {
34-
$this->content = $content;
35-
$this->versionInfo = $versionInfo;
36-
$this->languageCode = $languageCode;
3728
}
3829

3930
public function getContent(): Content

src/contracts/Event/ContentOnTheFlyEvents.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,13 @@
88

99
namespace Ibexa\Contracts\AdminUi\Event;
1010

11-
final class ContentOnTheFlyEvents
11+
final readonly class ContentOnTheFlyEvents
1212
{
13-
/** @var string */
14-
public const CONTENT_CREATE = 'ibexa.content_on_the_fly.create';
13+
public const string CONTENT_CREATE = 'ibexa.content_on_the_fly.create';
1514

16-
/** @var string */
17-
public const CONTENT_CREATE_PUBLISH = 'ibexa.content_on_the_fly.create.publish';
15+
public const string CONTENT_CREATE_PUBLISH = 'ibexa.content_on_the_fly.create.publish';
1816

19-
/** @var string */
20-
public const CONTENT_EDIT = 'ibexa.content_on_the_fly.edit';
17+
public const string CONTENT_EDIT = 'ibexa.content_on_the_fly.edit';
2118

22-
/** @var string */
23-
public const CONTENT_EDIT_PUBLISH = 'ibexa.content_on_the_fly.edit.publish';
19+
public const string CONTENT_EDIT_PUBLISH = 'ibexa.content_on_the_fly.edit.publish';
2420
}

src/contracts/Event/ContentProxyCreateEvent.php

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,28 +18,19 @@
1818
*/
1919
class ContentProxyCreateEvent extends Event
2020
{
21-
public const OPTION_CONTENT_DRAFT = 'contentDraft';
22-
public const OPTION_IS_ON_THE_FLY = 'isOnTheFly';
21+
public const string OPTION_CONTENT_DRAFT = 'contentDraft';
22+
public const string OPTION_IS_ON_THE_FLY = 'isOnTheFly';
2323

2424
private ?Response $response = null;
2525

26-
private ContentType $contentType;
27-
28-
private string $languageCode;
29-
30-
private int $parentLocationId;
31-
3226
private Options $options;
3327

3428
public function __construct(
35-
ContentType $contentType,
36-
string $languageCode,
37-
int $parentLocationId,
29+
private readonly ContentType $contentType,
30+
private readonly string $languageCode,
31+
private readonly int $parentLocationId,
3832
?Options $options = null
3933
) {
40-
$this->contentType = $contentType;
41-
$this->languageCode = $languageCode;
42-
$this->parentLocationId = $parentLocationId;
4334
$this->options = $options ?? new Options();
4435
}
4536

src/contracts/Event/ContentProxyTranslateEvent.php

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,28 +19,16 @@ class ContentProxyTranslateEvent extends Event
1919
{
2020
private ?Response $response = null;
2121

22-
private int $contentId;
23-
24-
private ?string $fromLanguageCode;
25-
26-
private string $toLanguageCode;
27-
2822
private Options $options;
2923

30-
private ?int $locationId;
31-
3224
public function __construct(
33-
int $contentId,
34-
?string $fromLanguageCode,
35-
string $toLanguageCode,
25+
private readonly int $contentId,
26+
private readonly ?string $fromLanguageCode,
27+
private readonly string $toLanguageCode,
3628
?Options $options = null,
37-
?int $locationId = null
29+
private readonly ?int $locationId = null
3830
) {
39-
$this->contentId = $contentId;
40-
$this->fromLanguageCode = $fromLanguageCode;
41-
$this->toLanguageCode = $toLanguageCode;
4231
$this->options = $options ?? new Options();
43-
$this->locationId = $locationId;
4432
}
4533

4634
public function getContentId(): int

src/contracts/Event/FieldDefinitionMappingEvent.php

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,18 @@
1313
use Ibexa\Contracts\Core\Repository\Values\ContentType\FieldDefinition;
1414
use Symfony\Contracts\EventDispatcher\Event;
1515

16-
class FieldDefinitionMappingEvent extends Event
16+
final class FieldDefinitionMappingEvent extends Event
1717
{
1818
/**
1919
* Triggered when contentTypeData is created from contentTypeDraft.
2020
*/
21-
public const NAME = 'field_definition.mapping';
22-
23-
private FieldDefinitionData $fieldDefinitionData;
24-
25-
private ?Language $baseLanguage;
26-
27-
private ?Language $targetLanguage;
21+
public const string NAME = 'field_definition.mapping';
2822

2923
public function __construct(
30-
FieldDefinitionData $fieldDefinitionData,
31-
?Language $baseLanguage,
32-
?Language $targetLanguage
24+
private FieldDefinitionData $fieldDefinitionData,
25+
private readonly ?Language $baseLanguage,
26+
private readonly ?Language $targetLanguage
3327
) {
34-
$this->baseLanguage = $baseLanguage;
35-
$this->targetLanguage = $targetLanguage;
36-
$this->fieldDefinitionData = $fieldDefinitionData;
3728
}
3829

3930
public function getFieldDefinition(): FieldDefinition

src/contracts/Event/FocusModeChangedEvent.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,8 @@
1212

1313
final class FocusModeChangedEvent extends Event
1414
{
15-
private bool $enabled;
16-
17-
public function __construct(bool $enabled)
15+
public function __construct(private readonly bool $enabled)
1816
{
19-
$this->enabled = $enabled;
2017
}
2118

2219
public function isEnabled(): bool

src/contracts/Event/FormActionEvent.php

Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -12,47 +12,26 @@
1212
use Symfony\Component\Form\FormInterface;
1313
use Symfony\Component\HttpFoundation\Response;
1414

15-
class FormActionEvent extends FormEvent
15+
final class FormActionEvent extends FormEvent
1616
{
17-
/**
18-
* Name of the button used to submit the form.
19-
*/
20-
private ?string $clickedButton;
21-
22-
/**
23-
* Hash of options.
24-
*
25-
* @var array<string, mixed>
26-
*/
27-
private array $options;
28-
2917
/**
3018
* Response to return after form post-processing. Typically, a RedirectResponse.
3119
*/
32-
private ?Response $response;
33-
34-
/**
35-
* Additional payload populated for event listeners next in priority.
36-
*
37-
* @var array<mixed>
38-
*/
39-
private array $payloads;
20+
private ?Response $response = null;
4021

4122
/**
23+
* @param \Symfony\Component\Form\FormInterface<mixed> $form
4224
* @param array<string, mixed> $options
43-
* @param array<mixed> $payloads
25+
* @param array<mixed> $payloads additional payloads populated for event listeners next in priority
4426
*/
4527
public function __construct(
4628
FormInterface $form,
4729
mixed $data,
48-
?string $clickedButton,
49-
array $options = [],
50-
array $payloads = []
30+
private readonly ?string $clickedButton,
31+
private readonly array $options = [],
32+
private array $payloads = []
5133
) {
5234
parent::__construct($form, $data);
53-
$this->clickedButton = $clickedButton;
54-
$this->options = $options;
55-
$this->payloads = $payloads;
5635
}
5736

5837
public function getClickedButton(): ?string

0 commit comments

Comments
 (0)