Skip to content

Commit

Permalink
Merged branch '4.6' into 'main' (#376)
Browse files Browse the repository at this point in the history
This is an up-merge of ezsystems/ezplatform-kernel#397. See also #376 for more details
  • Loading branch information
alongosz authored Jun 5, 2024
2 parents eeb08b4 + 15c129d commit 9654942
Show file tree
Hide file tree
Showing 29 changed files with 1,172 additions and 359 deletions.
2 changes: 1 addition & 1 deletion COPYRIGHT
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (C) 1999-2021 Ibexa AS (formerly eZ Systems AS). All rights reserved.
Copyright (C) 1999-2024 Ibexa AS (formerly eZ Systems AS). All rights reserved.

This source code is available separately under the following licenses:

Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (C) 1999-2021 Ibexa AS (formerly eZ Systems AS). All rights reserved.
Copyright (C) 1999-2024 Ibexa AS (formerly eZ Systems AS). All rights reserved.

This source code is available separately under the following licenses:

Expand Down
116 changes: 8 additions & 108 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -10990,6 +10990,11 @@ parameters:
count: 1
path: src/lib/IO/IOService.php

-
message: "#^Parameter \\#2 \\$length of function fread expects int\\<1, max\\>, int\\<0, max\\> given\\.$#"
count: 1
path: src/lib/IO/IOService.php

-
message: "#^Property Ibexa\\\\Contracts\\\\Core\\\\IO\\\\BinaryFile\\:\\:\\$uri \\(string\\) in isset\\(\\) is not nullable\\.$#"
count: 2
Expand Down Expand Up @@ -14885,11 +14890,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 @@ -16740,26 +16740,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 @@ -16800,16 +16780,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 @@ -18635,11 +18605,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 @@ -28972,7 +28937,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 @@ -48346,7 +48311,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 @@ -51986,7 +51951,7 @@ parameters:
path: tests/lib/Persistence/Legacy/Content/MapperTest.php

-
message: "#^Method Ibexa\\\\Tests\\\\Core\\\\Persistence\\\\Legacy\\\\Content\\\\MapperTest\\:\\:getLanguageHandler\\(\\) should return Ibexa\\\\Core\\\\Persistence\\\\Legacy\\\\Content\\\\Language\\\\Handler but returns Ibexa\\\\Contracts\\\\Core\\\\Persistence\\\\Content\\\\Language\\\\Handler\\.$#"
message: "#^Method Ibexa\\\\Tests\\\\Core\\\\Persistence\\\\Legacy\\\\Content\\\\MapperTest\\:\\:getLanguageHandler\\(\\) should return Ibexa\\\\Core\\\\Persistence\\\\Legacy\\\\Content\\\\Language\\\\Handler&PHPUnit\\\\Framework\\\\MockObject\\\\MockObject but returns Ibexa\\\\Contracts\\\\Core\\\\Persistence\\\\Content\\\\Language\\\\Handler\\.$#"
count: 1
path: tests/lib/Persistence/Legacy/Content/MapperTest.php

Expand Down Expand Up @@ -52520,71 +52485,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
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;

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,4 +86,12 @@ public function getFieldTypeIdentifier(): string
{
return $this->fieldTypeIdentifier;
}

/**
* @phpstan-assert-if-true !null $this->getId()
*/
public function isVirtual(): bool
{
return null === $this->id;
}
}
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 @@ -149,9 +149,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

0 comments on commit 9654942

Please sign in to comment.