From f5366937018dcb2b9a4533648a97021200b7ab0a Mon Sep 17 00:00:00 2001 From: Andrew Longosz Date: Fri, 8 Mar 2024 22:18:14 +0100 Subject: [PATCH 1/3] Introduced Value Object strict getters and deprecated magic ones --- src/lib/Strategy/DefaultThumbnailStrategy.php | 4 +-- src/lib/UserSetting/UserSetting.php | 29 +++++++++++++++---- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/src/lib/Strategy/DefaultThumbnailStrategy.php b/src/lib/Strategy/DefaultThumbnailStrategy.php index ede78f4..2ecd698 100644 --- a/src/lib/Strategy/DefaultThumbnailStrategy.php +++ b/src/lib/Strategy/DefaultThumbnailStrategy.php @@ -57,8 +57,8 @@ private function getInitials(array $fields): string foreach ($this->initialsFieldDefIdentifiers as $identifier) { /** @var \Ibexa\Contracts\Core\Repository\Values\Content\Field $field */ foreach ($fields as $field) { - if ($field->fieldDefIdentifier === $identifier) { - $initials .= substr((string)$field->value, 0, 1); + if ($field->getFieldDefinitionIdentifier() === $identifier) { + $initials .= substr((string)$field->getValue(), 0, 1); } } } diff --git a/src/lib/UserSetting/UserSetting.php b/src/lib/UserSetting/UserSetting.php index 3b90145..a9a2e65 100644 --- a/src/lib/UserSetting/UserSetting.php +++ b/src/lib/UserSetting/UserSetting.php @@ -11,16 +11,15 @@ use Ibexa\Contracts\Core\Repository\Values\ValueObject; /** - * @property string $identifier - * @property string $name - * @property string $description - * @property string $value + * @property string $identifier @deprecated use {@see UserSetting::getIdentifier()} instead. + * @property string $name @deprecated use {@see UserSetting::getName()} instead. + * @property string $description @deprecated use {@see UserSetting::getDescription()} instead. + * @property string $value @deprecated use {@see UserSetting::getValue()} instead. */ class UserSetting extends ValueObject { /** @var string */ protected $identifier; - /** @var string */ protected $name; @@ -29,6 +28,26 @@ class UserSetting extends ValueObject /** @var string */ protected $value; + + public function getIdentifier(): string + { + return $this->identifier; + } + + public function getName(): string + { + return $this->name; + } + + public function getDescription(): string + { + return $this->description; + } + + public function getValue(): string + { + return $this->value; + } } class_alias(UserSetting::class, 'EzSystems\EzPlatformUser\UserSetting\UserSetting'); From 8e68224c2eca4eff39de2680d4f155198cb01186 Mon Sep 17 00:00:00 2001 From: Andrew Longosz Date: Thu, 23 May 2024 23:00:25 +0200 Subject: [PATCH 2/3] [CS] Fixed outstanding CS issue in UserSetting class --- src/lib/UserSetting/UserSetting.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib/UserSetting/UserSetting.php b/src/lib/UserSetting/UserSetting.php index a9a2e65..219bc88 100644 --- a/src/lib/UserSetting/UserSetting.php +++ b/src/lib/UserSetting/UserSetting.php @@ -20,6 +20,7 @@ class UserSetting extends ValueObject { /** @var string */ protected $identifier; + /** @var string */ protected $name; From 4e13ab56cb2e2c8bf1f5d1d1363fab971e81ee73 Mon Sep 17 00:00:00 2001 From: Andrew Longosz Date: Fri, 24 May 2024 16:02:11 +0200 Subject: [PATCH 3/3] Fixed @property-read deprecation message to follow the convention Co-Authored-By: Konrad Oboza --- src/lib/UserSetting/UserSetting.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib/UserSetting/UserSetting.php b/src/lib/UserSetting/UserSetting.php index 219bc88..177d4dc 100644 --- a/src/lib/UserSetting/UserSetting.php +++ b/src/lib/UserSetting/UserSetting.php @@ -11,10 +11,10 @@ use Ibexa\Contracts\Core\Repository\Values\ValueObject; /** - * @property string $identifier @deprecated use {@see UserSetting::getIdentifier()} instead. - * @property string $name @deprecated use {@see UserSetting::getName()} instead. - * @property string $description @deprecated use {@see UserSetting::getDescription()} instead. - * @property string $value @deprecated use {@see UserSetting::getValue()} instead. + * @property string $identifier @deprecated 4.6.7 accessing magic getter is deprecated and will be removed in 5.0.0. Use {@see UserSetting::getIdentifier()} instead. + * @property string $name @deprecated 4.6.7 accessing magic getter is deprecated and will be removed in 5.0.0. Use {@see UserSetting::getName()} instead. + * @property string $description @deprecated 4.6.7 accessing magic getter is deprecated and will be removed in 5.0.0. Use {@see UserSetting::getDescription()} instead. + * @property string $value @deprecated 4.6.7 accessing magic getter is deprecated and will be removed in 5.0.0. Use {@see UserSetting::getValue()} instead. */ class UserSetting extends ValueObject {