Skip to content
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

Merge branch '1.3' of ezsystems/ezplatform-kernel into 4.6 #369

Merged
merged 2 commits into from
May 29, 2024
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
109 changes: 2 additions & 107 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -14985,11 +14985,6 @@ parameters:
count: 1
path: src/lib/Persistence/Legacy/Content/FieldHandler.php

-
message: "#^Method Ibexa\\\\Core\\\\Persistence\\\\Legacy\\\\Content\\\\FieldHandler\\:\\:createExistingFieldsInNewVersion\\(\\) has no return type specified\\.$#"
count: 1
path: src/lib/Persistence/Legacy/Content/FieldHandler.php

-
message: "#^Method Ibexa\\\\Core\\\\Persistence\\\\Legacy\\\\Content\\\\FieldHandler\\:\\:createNewField\\(\\) has no return type specified\\.$#"
count: 1
Expand Down Expand Up @@ -16840,26 +16835,6 @@ parameters:
count: 2
path: src/lib/Persistence/Legacy/Content/Location/Trash/Handler.php

-
message: "#^Method Ibexa\\\\Core\\\\Persistence\\\\Legacy\\\\Content\\\\Mapper\\:\\:extractContentFromRows\\(\\) has parameter \\$nameRows with no value type specified in iterable type array\\.$#"
count: 1
path: src/lib/Persistence/Legacy/Content/Mapper.php

-
message: "#^Method Ibexa\\\\Core\\\\Persistence\\\\Legacy\\\\Content\\\\Mapper\\:\\:extractContentFromRows\\(\\) has parameter \\$prefix with no type specified\\.$#"
count: 1
path: src/lib/Persistence/Legacy/Content/Mapper.php

-
message: "#^Method Ibexa\\\\Core\\\\Persistence\\\\Legacy\\\\Content\\\\Mapper\\:\\:extractContentFromRows\\(\\) has parameter \\$rows with no value type specified in iterable type array\\.$#"
count: 1
path: src/lib/Persistence/Legacy/Content/Mapper.php

-
message: "#^Method Ibexa\\\\Core\\\\Persistence\\\\Legacy\\\\Content\\\\Mapper\\:\\:extractContentInfoFromRow\\(\\) has parameter \\$row with no value type specified in iterable type array\\.$#"
count: 1
path: src/lib/Persistence/Legacy/Content/Mapper.php

-
message: "#^Method Ibexa\\\\Core\\\\Persistence\\\\Legacy\\\\Content\\\\Mapper\\:\\:extractContentInfoFromRows\\(\\) has parameter \\$rows with no value type specified in iterable type array\\.$#"
count: 1
Expand Down Expand Up @@ -16900,16 +16875,6 @@ parameters:
count: 1
path: src/lib/Persistence/Legacy/Content/Mapper.php

-
message: "#^Method Ibexa\\\\Core\\\\Persistence\\\\Legacy\\\\Content\\\\Mapper\\:\\:extractVersionInfoListFromRows\\(\\) has parameter \\$nameRows with no value type specified in iterable type array\\.$#"
count: 1
path: src/lib/Persistence/Legacy/Content/Mapper.php

-
message: "#^Method Ibexa\\\\Core\\\\Persistence\\\\Legacy\\\\Content\\\\Mapper\\:\\:extractVersionInfoListFromRows\\(\\) has parameter \\$rows with no value type specified in iterable type array\\.$#"
count: 1
path: src/lib/Persistence/Legacy/Content/Mapper.php

-
message: "#^Property Ibexa\\\\Contracts\\\\Core\\\\Persistence\\\\Content\\\\Field\\:\\:\\$id \\(int\\) does not accept null\\.$#"
count: 1
Expand Down Expand Up @@ -18740,11 +18705,6 @@ parameters:
count: 1
path: src/lib/Persistence/Legacy/Setting/Gateway/ExceptionConversion.php

-
message: "#^Cannot call method fetch\\(\\) on Doctrine\\\\DBAL\\\\ForwardCompatibility\\\\Result\\|int\\|string\\.$#"
count: 1
path: src/lib/Persistence/Legacy/SharedGateway/DatabasePlatform/SqliteGateway.php

-
message: "#^Argument of an invalid type array\\<Ibexa\\\\Core\\\\Persistence\\\\Legacy\\\\SharedGateway\\\\Gateway\\>\\|iterable supplied for foreach, only iterables are supported\\.$#"
count: 1
Expand Down Expand Up @@ -29182,7 +29142,7 @@ parameters:

-
message: "#^Parameter \\#2 \\$fieldDefinition of method Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\ContentTypeService\\:\\:removeFieldDefinition\\(\\) expects Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\ContentType\\\\FieldDefinition, Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\ContentType\\\\FieldDefinition\\|null given\\.$#"
count: 7
count: 6
path: tests/integration/Core/Repository/ContentTypeServiceTest.php

-
Expand Down Expand Up @@ -48816,7 +48776,7 @@ parameters:
path: tests/lib/MVC/Symfony/Templating/Twig/Extension/FileSystemTwigIntegrationTestCase.php

-
message: "#^Anonymous function should return string but returns string\\|false\\.$#"
message: "#^Anonymous function should return non\\-empty\\-string but returns non\\-empty\\-string\\|false\\.$#"
count: 1
path: tests/lib/MVC/Symfony/Templating/Twig/Extension/RoutingExtensionTest.php

Expand Down Expand Up @@ -53005,71 +52965,6 @@ parameters:
count: 1
path: tests/lib/Persistence/Legacy/Content/Section/SectionHandlerTest.php

-
message: "#^Call to an undefined method Ibexa\\\\Contracts\\\\Core\\\\FieldType\\\\FieldStorage\\:\\:expects\\(\\)\\.$#"
count: 6
path: tests/lib/Persistence/Legacy/Content/StorageHandlerTest.php

-
message: "#^Call to an undefined method Ibexa\\\\Core\\\\Persistence\\\\Legacy\\\\Content\\\\StorageRegistry\\:\\:expects\\(\\)\\.$#"
count: 4
path: tests/lib/Persistence/Legacy/Content/StorageHandlerTest.php

-
message: "#^Method Ibexa\\\\Tests\\\\Core\\\\Persistence\\\\Legacy\\\\Content\\\\StorageHandlerTest\\:\\:getContextMock\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: tests/lib/Persistence/Legacy/Content/StorageHandlerTest.php

-
message: "#^Method Ibexa\\\\Tests\\\\Core\\\\Persistence\\\\Legacy\\\\Content\\\\StorageHandlerTest\\:\\:getVersionInfoMock\\(\\) has no return type specified\\.$#"
count: 1
path: tests/lib/Persistence/Legacy/Content/StorageHandlerTest.php

-
message: "#^Method Ibexa\\\\Tests\\\\Core\\\\Persistence\\\\Legacy\\\\Content\\\\StorageHandlerTest\\:\\:testDeleteFieldData\\(\\) has no return type specified\\.$#"
count: 1
path: tests/lib/Persistence/Legacy/Content/StorageHandlerTest.php

-
message: "#^Method Ibexa\\\\Tests\\\\Core\\\\Persistence\\\\Legacy\\\\Content\\\\StorageHandlerTest\\:\\:testGetFieldDataAvailable\\(\\) has no return type specified\\.$#"
count: 1
path: tests/lib/Persistence/Legacy/Content/StorageHandlerTest.php

-
message: "#^Method Ibexa\\\\Tests\\\\Core\\\\Persistence\\\\Legacy\\\\Content\\\\StorageHandlerTest\\:\\:testGetFieldDataNotAvailable\\(\\) has no return type specified\\.$#"
count: 1
path: tests/lib/Persistence/Legacy/Content/StorageHandlerTest.php

-
message: "#^Method Ibexa\\\\Tests\\\\Core\\\\Persistence\\\\Legacy\\\\Content\\\\StorageHandlerTest\\:\\:testStoreFieldData\\(\\) has no return type specified\\.$#"
count: 1
path: tests/lib/Persistence/Legacy/Content/StorageHandlerTest.php

-
message: "#^Property Ibexa\\\\Tests\\\\Core\\\\Persistence\\\\Legacy\\\\Content\\\\StorageHandlerTest\\:\\:\\$storageHandler \\(Ibexa\\\\Core\\\\Persistence\\\\Legacy\\\\Content\\\\StorageHandler\\) in isset\\(\\) is not nullable\\.$#"
count: 1
path: tests/lib/Persistence/Legacy/Content/StorageHandlerTest.php

-
message: "#^Property Ibexa\\\\Tests\\\\Core\\\\Persistence\\\\Legacy\\\\Content\\\\StorageHandlerTest\\:\\:\\$storageMock \\(Ibexa\\\\Contracts\\\\Core\\\\FieldType\\\\FieldStorage\\) in isset\\(\\) is not nullable\\.$#"
count: 1
path: tests/lib/Persistence/Legacy/Content/StorageHandlerTest.php

-
message: "#^Property Ibexa\\\\Tests\\\\Core\\\\Persistence\\\\Legacy\\\\Content\\\\StorageHandlerTest\\:\\:\\$storageRegistryMock \\(Ibexa\\\\Core\\\\Persistence\\\\Legacy\\\\Content\\\\StorageRegistry\\) in isset\\(\\) is not nullable\\.$#"
count: 1
path: tests/lib/Persistence/Legacy/Content/StorageHandlerTest.php

-
message: "#^Property Ibexa\\\\Tests\\\\Core\\\\Persistence\\\\Legacy\\\\Content\\\\StorageHandlerTest\\:\\:\\$versionInfoMock \\(Ibexa\\\\Core\\\\Repository\\\\Values\\\\Content\\\\VersionInfo\\) does not accept Ibexa\\\\Contracts\\\\Core\\\\Persistence\\\\Content\\\\VersionInfo&PHPUnit\\\\Framework\\\\MockObject\\\\MockObject\\.$#"
count: 1
path: tests/lib/Persistence/Legacy/Content/StorageHandlerTest.php

-
message: "#^Property Ibexa\\\\Tests\\\\Core\\\\Persistence\\\\Legacy\\\\Content\\\\StorageHandlerTest\\:\\:\\$versionInfoMock \\(Ibexa\\\\Core\\\\Repository\\\\Values\\\\Content\\\\VersionInfo\\) in isset\\(\\) is not nullable\\.$#"
count: 1
path: tests/lib/Persistence/Legacy/Content/StorageHandlerTest.php

-
message: "#^Method Ibexa\\\\Tests\\\\Core\\\\Persistence\\\\Legacy\\\\Content\\\\StorageRegistryTest\\:\\:testGetNotFound\\(\\) has no return type specified\\.$#"
count: 1
Nattfarinn marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
77 changes: 77 additions & 0 deletions src/contracts/Event/Mapper/ResolveMissingFieldEvent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?php

/**
* @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\Contracts\Core\Event\Mapper;
Nattfarinn marked this conversation as resolved.
Show resolved Hide resolved

use Ibexa\Contracts\Core\Persistence\Content;
use Ibexa\Contracts\Core\Persistence\Content\Field;
use Ibexa\Contracts\Core\Persistence\Content\Type\FieldDefinition;
use Symfony\Contracts\EventDispatcher\Event;

final class ResolveMissingFieldEvent extends Event
{
private Content $content;

private FieldDefinition $fieldDefinition;

private string $languageCode;

/** @var array<mixed> */
private array $context;

private ?Field $field;

/**
* @param array<mixed> $context
*/
public function __construct(
Content $content,
FieldDefinition $fieldDefinition,
string $languageCode,
array $context = []
) {
$this->content = $content;
$this->fieldDefinition = $fieldDefinition;
$this->languageCode = $languageCode;
$this->context = $context;
$this->field = null;
}

public function getContent(): Content
{
return $this->content;
}

public function getFieldDefinition(): FieldDefinition
{
return $this->fieldDefinition;
}

public function getLanguageCode(): string
{
return $this->languageCode;
}

/**
* @return array<mixed>
*/
public function getContext(): array
{
return $this->context;
}

public function setField(?Field $field): void
{
$this->field = $field;
}

public function getField(): ?Field
{
return $this->field;
}
}
24 changes: 24 additions & 0 deletions src/contracts/FieldType/DefaultDataFieldStorage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

/**
* @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\Contracts\Core\FieldType;

use Ibexa\Contracts\Core\Persistence\Content\Field;
use Ibexa\Contracts\Core\Persistence\Content\VersionInfo;

interface DefaultDataFieldStorage extends FieldStorage
{
/**
* Populates <code>$field</code> value property with default data based on the external data.
*
* <code>$field->value</code> is a {@see \Ibexa\Contracts\Core\Persistence\Content\FieldValue} object.
* This value holds the data as a {@see \Ibexa\Core\FieldType\Value} based object, according to
* the field type (e.g. for <code>TextLine</code>, it will be a {@see \Ibexa\Core\FieldType\TextLine\Value} object).
*/
public function getDefaultFieldData(VersionInfo $versionInfo, Field $field): void;
}
13 changes: 11 additions & 2 deletions src/contracts/Repository/Values/Content/Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ class Field extends ValueObject
/**
* The field id.
*
* @todo may be not needed
* Value of `null` indicates the field is virtual
* and is not persisted (yet).
*
* @var mixed
*/
Expand Down Expand Up @@ -58,7 +59,7 @@ class Field extends ValueObject
*/
protected $fieldTypeIdentifier;

public function getId(): int
public function getId(): ?int
{
return $this->id;
}
Expand All @@ -85,6 +86,14 @@ public function getFieldTypeIdentifier(): string
{
return $this->fieldTypeIdentifier;
}

/**
* @phpstan-assert-if-true !null $this->getId()
*/
public function isVirtual(): bool
{
return null === $this->id;
}
}

class_alias(Field::class, 'eZ\Publish\API\Repository\Values\Content\Field');
6 changes: 5 additions & 1 deletion src/lib/Persistence/Legacy/Content/FieldHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,13 @@ protected function getEmptyField(FieldDefinition $fieldDefinition, $languageCode
*
* @param \Ibexa\Contracts\Core\Persistence\Content $content
*/
public function createExistingFieldsInNewVersion(Content $content)
public function createExistingFieldsInNewVersion(Content $content): void
{
foreach ($content->fields as $field) {
if ($field->id === null) {
// Virtual field with default value, skip creating field as it has no id
continue;
}
$this->createExistingFieldInNewVersion($field, $content);
}
}
Expand Down
Loading
Loading