From 4c28a4c35833179f3b9613711f6a3e3fb5a9dfeb Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Tue, 5 Aug 2025 09:03:53 +0200 Subject: [PATCH] refactor: improve property checks - use ClassUtils for real class name resolution in ActivityType --- src/Bundle/ChillActivityBundle/Entity/ActivityType.php | 7 +++++-- .../ChillMainBundle/Templating/TranslatableStringTwig.php | 4 +--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Entity/ActivityType.php b/src/Bundle/ChillActivityBundle/Entity/ActivityType.php index d27fc1784..ec1012136 100644 --- a/src/Bundle/ChillActivityBundle/Entity/ActivityType.php +++ b/src/Bundle/ChillActivityBundle/Entity/ActivityType.php @@ -11,6 +11,7 @@ declare(strict_types=1); namespace Chill\ActivityBundle\Entity; +use Doctrine\Common\Util\ClassUtils; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Serializer\Annotation as Serializer; use Symfony\Component\Serializer\Annotation\Groups; @@ -461,11 +462,13 @@ class ActivityType { $property = $field.'Visible'; - if (!property_exists($this, $property)) { + // Get the real class name (not the proxy) + $realClass = ClassUtils::getClass($this); + + if (!property_exists($realClass, $property)) { throw new \InvalidArgumentException('Field "'.$field.'" not found'); } - /* @phpstan-ignore-next-line */ return self::FIELD_INVISIBLE !== $this->{$property}; } diff --git a/src/Bundle/ChillMainBundle/Templating/TranslatableStringTwig.php b/src/Bundle/ChillMainBundle/Templating/TranslatableStringTwig.php index c6bbc11ea..a9b551b81 100644 --- a/src/Bundle/ChillMainBundle/Templating/TranslatableStringTwig.php +++ b/src/Bundle/ChillMainBundle/Templating/TranslatableStringTwig.php @@ -42,10 +42,8 @@ class TranslatableStringTwig extends AbstractExtension /** * Returns the name of the extension. - * - * @return The name of the extension */ - public function getName() + public function getName(): string { return 'chill_main_localize'; }