+
Skip to content
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
30 changes: 0 additions & 30 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -20820,12 +20820,6 @@ parameters:
count: 1
path: src/lib/Repository/Values/ContentType/ContentType.php

-
message: '#^Method Ibexa\\Core\\Repository\\Values\\ContentType\\ContentType\:\:getName\(\) should return string\|null but returns string\|false\.$#'
identifier: return.type
count: 1
path: src/lib/Repository/Values/ContentType/ContentType.php

-
message: '#^Method Ibexa\\Core\\Repository\\Values\\ContentType\\ContentTypeDraft\:\:getProperties\(\) has parameter \$dynamicProperties with no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
Expand All @@ -20850,12 +20844,6 @@ parameters:
count: 1
path: src/lib/Repository/Values/ContentType/ContentTypeGroup.php

-
message: '#^Method Ibexa\\Core\\Repository\\Values\\ContentType\\ContentTypeGroup\:\:getName\(\) should return string\|null but returns string\|false\.$#'
identifier: return.type
count: 1
path: src/lib/Repository/Values/ContentType/ContentTypeGroup.php

-
message: '#^Class Ibexa\\Core\\Repository\\Values\\ContentType\\FieldDefinition has PHPDoc tag @property\-read for property \$fieldSettings with no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
Expand All @@ -20880,12 +20868,6 @@ parameters:
count: 1
path: src/lib/Repository/Values/ContentType/FieldDefinition.php

-
message: '#^Method Ibexa\\Core\\Repository\\Values\\ContentType\\FieldDefinition\:\:getName\(\) should return string\|null but returns string\|false\.$#'
identifier: return.type
count: 1
path: src/lib/Repository/Values/ContentType/FieldDefinition.php

-
message: '#^Method Ibexa\\Core\\Repository\\Values\\ContentType\\FieldDefinition\:\:getValidatorConfiguration\(\) return type has no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
Expand Down Expand Up @@ -20964,24 +20946,12 @@ parameters:
count: 1
path: src/lib/Repository/Values/ObjectState/ObjectState.php

-
message: '#^Method Ibexa\\Core\\Repository\\Values\\ObjectState\\ObjectState\:\:getName\(\) should return string\|null but returns string\|false\.$#'
identifier: return.type
count: 1
path: src/lib/Repository/Values/ObjectState/ObjectState.php

-
message: '#^Method Ibexa\\Core\\Repository\\Values\\ObjectState\\ObjectStateGroup\:\:getDescription\(\) should return string\|null but returns string\|false\.$#'
identifier: return.type
count: 1
path: src/lib/Repository/Values/ObjectState/ObjectStateGroup.php

-
message: '#^Method Ibexa\\Core\\Repository\\Values\\ObjectState\\ObjectStateGroup\:\:getName\(\) should return string\|null but returns string\|false\.$#'
identifier: return.type
count: 1
path: src/lib/Repository/Values/ObjectState/ObjectStateGroup.php

-
message: '#^Property Ibexa\\Core\\Repository\\Values\\User\\PolicyDraft\:\:\$draftProperties type has no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
Expand Down
16 changes: 6 additions & 10 deletions src/contracts/Repository/Values/MultiLanguageName.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,20 @@
* Provides a uniform way for API consuming logic to generate translated names / labels
* for API objects.
* Language logic is meant to also be used for description, fields, ... lookup as well.
*
* @todo Move to API, Repository is not a SPI concept.
*/
interface MultiLanguageName
{
/**
* Return the human readable name in all provided languages.
* Return the human-readable name in all provided languages.
*
* The structure of the return value is:
* <code>
* array( 'eng' => '<name_eng>', 'de' => '<name_de>' );
* </code>
* ```
* ['eng' => '<name_eng>', 'de' => '<name_de>']
* ```
*
* @return string[]
*/
public function getNames();
public function getNames(): array;

/**
* Return the name of the domain object in a given language.
Expand All @@ -40,10 +38,8 @@ public function getNames();
* 2. Main language if object is $alwaysAvailable
* 3. Fallback to return in initial (version objects) or main language
*
* @param string|null $languageCode
*
* @return string|null The name for a given language, or null if $languageCode is not set
* or does not exist.
*/
public function getName($languageCode = null);
public function getName(?string $languageCode = null): ?string;
}
4 changes: 2 additions & 2 deletions src/lib/Repository/Values/Content/VersionInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,15 @@ public function getLanguages(): iterable
/**
* {@inheritdoc}
*/
public function getNames()
public function getNames(): array
{
return $this->names;
}

/**
* {@inheritdoc}
*/
public function getName($languageCode = null)
public function getName(?string $languageCode = null): ?string
{
if ($languageCode) {
return isset($this->names[$languageCode]) ? $this->names[$languageCode] : null;
Expand Down
4 changes: 2 additions & 2 deletions src/lib/Repository/Values/ContentType/ContentTypeDraft.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,15 @@ public function __isset($property)
/**
* {@inheritdoc}
*/
public function getNames()
public function getNames(): array
{
return $this->innerContentType->getNames();
}

/**
* {@inheritdoc}
*/
public function getName($languageCode = null)
public function getName(?string $languageCode = null): ?string
{
return $this->innerContentType->getName($languageCode);
}
Expand Down
23 changes: 10 additions & 13 deletions src/lib/Repository/Values/MultiLanguageNameTrait.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\Core\Repository\Values;

Expand All @@ -17,23 +18,17 @@ trait MultiLanguageNameTrait
*
* @var string[]
*/
protected $names = [];
protected array $names = [];

/**
* {@inheritdoc}
*/
public function getNames()
public function getNames(): array
{
return $this->names;
}

/**
* {@inheritdoc}
*/
public function getName($languageCode = null)
public function getName(?string $languageCode = null): ?string
{
if (!empty($languageCode)) {
return isset($this->names[$languageCode]) ? $this->names[$languageCode] : null;
return $this->names[$languageCode] ?? null;
}

foreach ($this->prioritizedLanguages as $prioritizedLanguageCode) {
Expand All @@ -42,8 +37,10 @@ public function getName($languageCode = null)
}
}

return isset($this->names[$this->mainLanguageCode])
? $this->names[$this->mainLanguageCode]
: reset($this->names);
if (isset($this->mainLanguageCode, $this->names[$this->mainLanguageCode])) {
Copy link
Member Author

@alongosz alongosz Jun 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

The content-forms bug is fixed by adding $this->mainLanguage to the isset list prior using it

return $this->names[$this->mainLanguageCode];
}

return $this->names[array_key_first($this->names)] ?? null;
}
}
Loading
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载