refactor: improve property checks

- use ClassUtils for real class name resolution in ActivityType
This commit is contained in:
2025-08-05 09:03:53 +02:00
parent 490d546e7a
commit 4c28a4c358
2 changed files with 6 additions and 5 deletions

View File

@@ -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};
}

View File

@@ -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';
}