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
10 changes: 0 additions & 10 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -8530,11 +8530,6 @@ parameters:
count: 1
path: src/lib/Base/Exceptions/UnauthorizedException.php

-
message: "#^Cannot cast Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Translation to string\\.$#"
count: 1
path: src/lib/Base/Exceptions/UserPasswordValidationException.php

-
message: "#^Method Ibexa\\\\Core\\\\Base\\\\Exceptions\\\\UserPasswordValidationException\\:\\:__construct\\(\\) has parameter \\$errors with no value type specified in iterable type array\\.$#"
count: 1
Expand Down Expand Up @@ -43040,11 +43035,6 @@ parameters:
count: 1
path: tests/lib/FieldType/FloatValueValidatorTest.php

-
message: "#^Cannot cast Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Translation to string\\.$#"
count: 1
path: tests/lib/FieldType/Generic/GenericTest.php

-
message: "#^Class Symfony\\\\Component\\\\Validator\\\\ConstraintViolation constructor invoked with 1 parameter, 6\\-10 required\\.$#"
count: 1
Expand Down
9 changes: 6 additions & 3 deletions src/contracts/Repository/Values/Translation.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@

namespace Ibexa\Contracts\Core\Repository\Values;

use Stringable;

/**
* Base class fro translation messages.
* Abstract for UI translation messages, use its extensions: Translation\Message, Translation\Plural.
*
* Use its extensions: Translation\Singular, Translation\Plural.
* @see \Ibexa\Contracts\Core\Repository\Values\Translation\Message
* @see \Ibexa\Contracts\Core\Repository\Values\Translation\Plural
*/
abstract class Translation extends ValueObject
abstract class Translation extends ValueObject implements Stringable
{
}

Expand Down
8 changes: 4 additions & 4 deletions src/contracts/Repository/Values/Translation/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ public function __construct($message, array $values = [])
{
$this->message = $message;
$this->values = $values;

parent::__construct();
}

/**
* {@inheritdoc}
*/
public function __toString()
#[\Override]
public function __toString(): string
{
return strtr($this->message, $this->values);
}
Expand Down
8 changes: 4 additions & 4 deletions src/contracts/Repository/Values/Translation/Plural.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ public function __construct($singular, $plural, array $values)
$this->singular = $singular;
$this->plural = $plural;
$this->values = $values;

parent::__construct();
}

/**
* {@inheritdoc}
*/
public function __toString()
#[\Override]
public function __toString(): string
{
return strtr(current($this->values) == 1 ? $this->plural : $this->singular, $this->values);
}
Expand Down