diff --git a/src/Entity/Attachments/Attachment.php b/src/Entity/Attachments/Attachment.php index cd979d78..003b7cd9 100644 --- a/src/Entity/Attachments/Attachment.php +++ b/src/Entity/Attachments/Attachment.php @@ -104,19 +104,13 @@ abstract class Attachment extends AbstractNamedDBElement */ protected ?AttachmentContainingDBElement $element = null; - /** - * @var bool - */ #[ORM\Column(type: Types::BOOLEAN)] protected bool $show_in_table = false; - /** - * @var AttachmentType|null - * @Selectable() - */ #[Assert\NotNull(message: 'validator.attachment.must_not_be_null')] #[ORM\ManyToOne(targetEntity: 'AttachmentType', inversedBy: 'attachments_with_type')] #[ORM\JoinColumn(name: 'type_id', nullable: false)] + #[Selectable()] protected ?AttachmentType $attachment_type = null; public function __construct() diff --git a/src/Entity/Attachments/AttachmentType.php b/src/Entity/Attachments/AttachmentType.php index 9bff255a..90e6baf7 100644 --- a/src/Entity/Attachments/AttachmentType.php +++ b/src/Entity/Attachments/AttachmentType.php @@ -50,12 +50,10 @@ class AttachmentType extends AbstractStructuralDBElement #[ORM\JoinColumn(name: 'parent_id')] protected ?AbstractStructuralDBElement $parent = null; - /** - * @var string - * @ValidFileFilter - */ #[ORM\Column(type: Types::TEXT)] + #[ValidFileFilter] protected string $filetype_filter = ''; + /** * @var Collection */ diff --git a/src/Entity/Base/AbstractStructuralDBElement.php b/src/Entity/Base/AbstractStructuralDBElement.php index 6e82a47d..0a5b6765 100644 --- a/src/Entity/Base/AbstractStructuralDBElement.php +++ b/src/Entity/Base/AbstractStructuralDBElement.php @@ -87,16 +87,13 @@ abstract class AbstractStructuralDBElement extends AttachmentContainingDBElement * We can not define the mapping here, or we will get an exception. Unfortunately we have to do the mapping in the * subclasses. * - * @var AbstractStructuralDBElement[]|Collection + * @var Collection */ #[Groups(['include_children'])] protected Collection $children; - /** - * @var AbstractStructuralDBElement - * @NoneOfItsChildren() - */ #[Groups(['include_parents', 'import'])] + #[NoneOfItsChildren] protected ?AbstractStructuralDBElement $parent = null; /** @var string[] all names of all parent elements as an array of strings, diff --git a/src/Entity/Parts/PartLot.php b/src/Entity/Parts/PartLot.php index f6a9d404..15cda250 100644 --- a/src/Entity/Parts/PartLot.php +++ b/src/Entity/Parts/PartLot.php @@ -41,7 +41,6 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface; * This entity describes a lot where parts can be stored. * It is the connection between a part and its store locations. * - * @ValidPartLot() * @see \App\Tests\Entity\Parts\PartLotTest */ #[ORM\Entity] @@ -49,6 +48,7 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface; #[ORM\Table(name: 'part_lots')] #[ORM\Index(name: 'part_lots_idx_instock_un_expiration_id_part', columns: ['instock_unknown', 'expiration_date', 'id_part'])] #[ORM\Index(name: 'part_lots_idx_needs_refill', columns: ['needs_refill'])] +#[ValidPartLot] class PartLot extends AbstractDBElement implements TimeStampableInterface, NamedElementInterface { use TimestampTrait; @@ -77,11 +77,11 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface, Named /** * @var Storelocation|null The storelocation of this lot - * @Selectable() */ #[Groups(['simple', 'extended', 'full', 'import'])] #[ORM\ManyToOne(targetEntity: 'Storelocation')] #[ORM\JoinColumn(name: 'id_store_location')] + #[Selectable()] protected ?Storelocation $storage_location = null; /** @@ -334,7 +334,7 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface, Named //When the storage location sets the owner must match, the part lot owner must match the storage location owner if ($this->getStorageLocation() && $this->getStorageLocation()->isPartOwnerMustMatch() && $this->getStorageLocation()->getOwner() && $this->getOwner() && ($this->getOwner() !== $this->getStorageLocation()->getOwner() - && $this->owner->getID() !== $this->getStorageLocation()->getOwner()->getID())) { + && $this->owner->getID() !== $this->getStorageLocation()->getOwner()->getID())) { $context->buildViolation('validator.part_lot.owner_must_match_storage_location_owner') ->setParameter('%owner_name%', $this->getStorageLocation()->getOwner()->getFullName(true)) ->atPath('owner') diff --git a/src/Entity/Parts/PartTraits/BasicPropertyTrait.php b/src/Entity/Parts/PartTraits/BasicPropertyTrait.php index aa08f514..192531e3 100644 --- a/src/Entity/Parts/PartTraits/BasicPropertyTrait.php +++ b/src/Entity/Parts/PartTraits/BasicPropertyTrait.php @@ -62,9 +62,9 @@ trait BasicPropertyTrait /** * @var Category|null The category this part belongs too (e.g. Resistors). Use tags, for more complex grouping. * Every part must have a category. - * @Selectable() */ #[Assert\NotNull(message: 'validator.select_valid_category')] + #[Selectable()] #[Groups(['simple', 'extended', 'full', 'import'])] #[ORM\ManyToOne(targetEntity: 'Category')] #[ORM\JoinColumn(name: 'id_category', nullable: false)] @@ -72,11 +72,11 @@ trait BasicPropertyTrait /** * @var Footprint|null The footprint of this part (e.g. DIP8) - * @Selectable() */ #[Groups(['simple', 'extended', 'full', 'import'])] #[ORM\ManyToOne(targetEntity: 'Footprint')] #[ORM\JoinColumn(name: 'id_footprint')] + #[Selectable()] protected ?Footprint $footprint = null; /** diff --git a/src/Entity/Parts/PartTraits/ManufacturerTrait.php b/src/Entity/Parts/PartTraits/ManufacturerTrait.php index 0a66dfa0..1aa3d988 100644 --- a/src/Entity/Parts/PartTraits/ManufacturerTrait.php +++ b/src/Entity/Parts/PartTraits/ManufacturerTrait.php @@ -37,11 +37,11 @@ trait ManufacturerTrait { /** * @var Manufacturer|null The manufacturer of this part - * @Selectable() */ #[Groups(['simple', 'extended', 'full', 'import'])] #[ORM\ManyToOne(targetEntity: 'Manufacturer')] #[ORM\JoinColumn(name: 'id_manufacturer')] + #[Selectable()] protected ?Manufacturer $manufacturer = null; /** diff --git a/src/Entity/Parts/Supplier.php b/src/Entity/Parts/Supplier.php index 2746f131..85fe6db4 100644 --- a/src/Entity/Parts/Supplier.php +++ b/src/Entity/Parts/Supplier.php @@ -70,18 +70,18 @@ class Supplier extends AbstractCompany /** * @var Currency|null The currency that should be used by default for order informations with this supplier. * Set to null, to use global base currency. - * @Selectable() */ #[ORM\ManyToOne(targetEntity: Currency::class)] #[ORM\JoinColumn(name: 'default_currency_id')] + #[Selectable()] protected ?Currency $default_currency = null; /** * @var BigDecimal|null the shipping costs that have to be paid, when ordering via this supplier - * @BigDecimalPositiveOrZero() */ #[Groups(['extended', 'full', 'import'])] #[ORM\Column(name: 'shipping_costs', nullable: true, type: 'big_decimal', precision: 11, scale: 5)] + #[BigDecimalPositiveOrZero()] protected ?BigDecimal $shipping_costs = null; /** diff --git a/src/Entity/PriceInformations/Currency.php b/src/Entity/PriceInformations/Currency.php index ea14cfcc..ac41acf2 100644 --- a/src/Entity/PriceInformations/Currency.php +++ b/src/Entity/PriceInformations/Currency.php @@ -51,9 +51,9 @@ class Currency extends AbstractStructuralDBElement /** * @var BigDecimal|null The exchange rate between this currency and the base currency * (how many base units the current currency is worth) - * @BigDecimalPositive() */ #[ORM\Column(type: 'big_decimal', precision: 11, scale: 5, nullable: true)] + #[BigDecimalPositive()] protected ?BigDecimal $exchange_rate = null; /** diff --git a/src/Entity/PriceInformations/Pricedetail.php b/src/Entity/PriceInformations/Pricedetail.php index 9847b41a..34df9e57 100644 --- a/src/Entity/PriceInformations/Pricedetail.php +++ b/src/Entity/PriceInformations/Pricedetail.php @@ -53,20 +53,20 @@ class Pricedetail extends AbstractDBElement implements TimeStampableInterface /** * @var BigDecimal The price related to the detail. (Given in the selected currency) - * @BigDecimalPositive() */ #[Groups(['extended', 'full'])] #[ORM\Column(type: 'big_decimal', precision: 11, scale: 5)] + #[BigDecimalPositive()] protected BigDecimal $price; /** * @var ?Currency The currency used for the current price information. - * If this is null, the global base unit is assumed. - * @Selectable() + * If this is null, the global base unit is assumed */ #[Groups(['extended', 'full', 'import'])] #[ORM\ManyToOne(targetEntity: 'Currency', inversedBy: 'pricedetails')] #[ORM\JoinColumn(name: 'id_currency')] + #[Selectable()] protected ?Currency $currency = null; /** diff --git a/src/Entity/ProjectSystem/ProjectBOMEntry.php b/src/Entity/ProjectSystem/ProjectBOMEntry.php index 0bc0186e..4469f86f 100644 --- a/src/Entity/ProjectSystem/ProjectBOMEntry.php +++ b/src/Entity/ProjectSystem/ProjectBOMEntry.php @@ -96,10 +96,10 @@ class ProjectBOMEntry extends AbstractDBElement /** * @var ?Currency The currency for the price of this non-part BOM entry - * @Selectable() */ #[ORM\ManyToOne(targetEntity: Currency::class)] #[ORM\JoinColumn] + #[Selectable] protected ?Currency $price_currency = null; public function __construct() diff --git a/src/Entity/UserSystem/Group.php b/src/Entity/UserSystem/Group.php index 6dceec58..b8647847 100644 --- a/src/Entity/UserSystem/Group.php +++ b/src/Entity/UserSystem/Group.php @@ -22,6 +22,7 @@ declare(strict_types=1); namespace App\Entity\UserSystem; +use App\Validator\Constraints\NoLockout; use Doctrine\DBAL\Types\Types; use App\Entity\Attachments\GroupAttachment; use App\Entity\Base\AbstractStructuralDBElement; @@ -41,6 +42,7 @@ use Symfony\Component\Validator\Constraints as Assert; #[ORM\Table('`groups`')] #[ORM\Index(name: 'group_idx_name', columns: ['name'])] #[ORM\Index(name: 'group_idx_parent_name', columns: ['parent_id', 'name'])] +#[NoLockout()] class Group extends AbstractStructuralDBElement implements HasPermissionsInterface { /** @@ -66,6 +68,7 @@ class Group extends AbstractStructuralDBElement implements HasPermissionsInterfa #[Groups(['extended', 'full', 'import'])] #[ORM\Column(type: Types::BOOLEAN, name: 'enforce_2fa')] protected bool $enforce2FA = false; + /** * @var Collection */ @@ -74,15 +77,13 @@ class Group extends AbstractStructuralDBElement implements HasPermissionsInterfa #[ORM\OrderBy(['name' => 'ASC'])] protected Collection $attachments; - /** - * @var PermissionData|null - * @ValidPermission() - */ #[Groups(['full'])] #[ORM\Embedded(class: 'PermissionData', columnPrefix: 'permissions_')] + #[ValidPermission()] protected ?PermissionData $permissions = null; - /** @var Collection + /** + * @var Collection */ #[Assert\Valid] #[ORM\OneToMany(targetEntity: GroupParameter::class, mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)] diff --git a/src/Entity/UserSystem/User.php b/src/Entity/UserSystem/User.php index 8f57c370..d92b0d91 100644 --- a/src/Entity/UserSystem/User.php +++ b/src/Entity/UserSystem/User.php @@ -24,6 +24,7 @@ namespace App\Entity\UserSystem; use App\Repository\UserRepository; use App\EntityListeners\TreeCacheInvalidationListener; +use App\Validator\Constraints\NoLockout; use Doctrine\DBAL\Types\Types; use App\Entity\Attachments\AttachmentContainingDBElement; use App\Entity\Attachments\UserAttachment; @@ -64,6 +65,7 @@ use Jbtronics\TFAWebauthn\Model\TwoFactorInterface as WebauthnTwoFactorInterface #[ORM\EntityListeners([TreeCacheInvalidationListener::class])] #[ORM\Table('`users`')] #[ORM\Index(name: 'user_idx_username', columns: ['name'])] +#[NoLockout()] class User extends AttachmentContainingDBElement implements UserInterface, HasPermissionsInterface, TwoFactorInterface, BackupCodeInterface, TrustedDeviceInterface, WebauthnTwoFactorInterface, PreferredProviderInterface, PasswordAuthenticatedUserInterface, SamlUserInterface { @@ -83,10 +85,10 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe /** * @var string|null The theme - * @ValidTheme() */ #[Groups(['full', 'import'])] #[ORM\Column(type: Types::STRING, name: 'config_theme', nullable: true)] + #[ValidTheme()] protected ?string $theme = null; /** @@ -127,11 +129,11 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe /** * @var Group|null the group this user belongs to * DO NOT PUT A fetch eager here! Otherwise, you can not unset the group of a user! This seems to be some kind of bug in doctrine. Maybe this is fixed in future versions. - * @Selectable() */ #[Groups(['extended', 'full', 'import'])] #[ORM\ManyToOne(targetEntity: 'Group', inversedBy: 'users')] #[ORM\JoinColumn(name: 'group_id')] + #[Selectable] protected ?Group $group = null; /** @@ -244,19 +246,16 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe * Dont use fetch=EAGER here, this will cause problems with setting the currency setting. * TODO: This is most likely a bug in doctrine/symfony related to the UniqueEntity constraint (it makes a db call). * TODO: Find a way to use fetch EAGER (this improves performance a bit) - * @Selectable() */ #[Groups(['extended', 'full', 'import'])] #[ORM\ManyToOne(targetEntity: Currency::class)] #[ORM\JoinColumn(name: 'currency_id')] + #[Selectable] protected ?Currency $currency = null; - /** - * @var PermissionData|null - * @ValidPermission() - */ #[Groups(['simple', 'extended', 'full', 'import'])] #[ORM\Embedded(class: 'PermissionData', columnPrefix: 'permissions_')] + #[ValidPermission()] protected ?PermissionData $permissions = null; /** @@ -287,7 +286,7 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe * * @return string */ - public function __toString() + public function __toString(): string { $tmp = $this->isDisabled() ? ' [DISABLED]' : ''; diff --git a/src/Helpers/Projects/ProjectBuildRequest.php b/src/Helpers/Projects/ProjectBuildRequest.php index 09dca3aa..c1c3c66f 100644 --- a/src/Helpers/Projects/ProjectBuildRequest.php +++ b/src/Helpers/Projects/ProjectBuildRequest.php @@ -29,9 +29,9 @@ use App\Entity\ProjectSystem\ProjectBOMEntry; use App\Validator\Constraints\ProjectSystem\ValidProjectBuildRequest; /** - * @ValidProjectBuildRequest() * @see \App\Tests\Helpers\Projects\ProjectBuildRequestTest */ +#[ValidProjectBuildRequest] final class ProjectBuildRequest { private readonly int $number_of_builds; diff --git a/src/Validator/Constraints/BigDecimal/BigDecimalPositive.php b/src/Validator/Constraints/BigDecimal/BigDecimalPositive.php index de66eea3..0e7e755f 100644 --- a/src/Validator/Constraints/BigDecimal/BigDecimalPositive.php +++ b/src/Validator/Constraints/BigDecimal/BigDecimalPositive.php @@ -22,25 +22,11 @@ declare(strict_types=1); */ namespace App\Validator\Constraints\BigDecimal; -use Symfony\Component\Validator\Constraints\GreaterThan; +use Symfony\Component\Validator\Constraints\Positive; -/** - * @Annotation - * @Target({"PROPERTY", "METHOD", "ANNOTATION"}) - * - * @author Jan Schädlich - */ -class BigDecimalPositive extends GreaterThan +#[\Attribute(\Attribute::TARGET_PROPERTY | \Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)] +class BigDecimalPositive extends Positive { - use BigNumberConstraintTrait; - - public $message = 'This value should be positive.'; - - public function __construct($options = null) - { - parent::__construct($this->configureNumberConstraintOptions($options)); - } - public function validatedBy(): string { return BigDecimalGreaterThanValidator::class; diff --git a/src/Validator/Constraints/BigDecimal/BigDecimalPositiveOrZero.php b/src/Validator/Constraints/BigDecimal/BigDecimalPositiveOrZero.php index 30042fe2..408cd582 100644 --- a/src/Validator/Constraints/BigDecimal/BigDecimalPositiveOrZero.php +++ b/src/Validator/Constraints/BigDecimal/BigDecimalPositiveOrZero.php @@ -22,25 +22,11 @@ declare(strict_types=1); */ namespace App\Validator\Constraints\BigDecimal; -use Symfony\Component\Validator\Constraints\GreaterThanOrEqual; +use Symfony\Component\Validator\Constraints\PositiveOrZero; -/** - * @Annotation - * @Target({"PROPERTY", "METHOD", "ANNOTATION"}) - * - * @author Jan Schädlich - */ -class BigDecimalPositiveOrZero extends GreaterThanOrEqual +#[\Attribute(\Attribute::TARGET_PROPERTY | \Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)] +class BigDecimalPositiveOrZero extends PositiveOrZero { - use BigNumberConstraintTrait; - - public $message = 'This value should be either positive or zero.'; - - public function __construct($options = null) - { - parent::__construct($this->configureNumberConstraintOptions($options)); - } - public function validatedBy(): string { return BigDecimalGreaterThenOrEqualValidator::class; diff --git a/src/Validator/Constraints/BigDecimal/BigNumberConstraintTrait.php b/src/Validator/Constraints/BigDecimal/BigNumberConstraintTrait.php deleted file mode 100644 index ba89900f..00000000 --- a/src/Validator/Constraints/BigDecimal/BigNumberConstraintTrait.php +++ /dev/null @@ -1,51 +0,0 @@ -. - */ -namespace App\Validator\Constraints\BigDecimal; - -use Symfony\Component\Validator\Exception\ConstraintDefinitionException; - -use function is_array; - -trait BigNumberConstraintTrait -{ - private function configureNumberConstraintOptions($options): array - { - if (null === $options) { - $options = []; - } elseif (!is_array($options)) { - $options = [$this->getDefaultOption() => $options]; - } - - if (isset($options['propertyPath'])) { - throw new ConstraintDefinitionException(sprintf('The "propertyPath" option of the "%s" constraint cannot be set.', static::class)); - } - - if (isset($options['value'])) { - throw new ConstraintDefinitionException(sprintf('The "value" option of the "%s" constraint cannot be set.', static::class)); - } - - $options['value'] = 0; - - return $options; - } -} diff --git a/src/Validator/Constraints/Misc/ValidRange.php b/src/Validator/Constraints/Misc/ValidRange.php index 15781498..680eb04d 100644 --- a/src/Validator/Constraints/Misc/ValidRange.php +++ b/src/Validator/Constraints/Misc/ValidRange.php @@ -43,9 +43,7 @@ namespace App\Validator\Constraints\Misc; use Symfony\Component\Validator\Constraint; -/** - * @Annotation - */ +#[\Attribute(\Attribute::TARGET_PROPERTY)] class ValidRange extends Constraint { public string $message = 'validator.invalid_range'; diff --git a/src/Validator/Constraints/NoLockout.php b/src/Validator/Constraints/NoLockout.php index 323dddb4..a33f3106 100644 --- a/src/Validator/Constraints/NoLockout.php +++ b/src/Validator/Constraints/NoLockout.php @@ -26,9 +26,8 @@ use Symfony\Component\Validator\Constraint; /** * This constraint restricts a user in that way that it can not lock itself out of the user system. - * - * @Annotation */ +#[\Attribute(\Attribute::TARGET_CLASS)] class NoLockout extends Constraint { public string $message = 'validator.noLockout'; diff --git a/src/Validator/Constraints/NoLockoutValidator.php b/src/Validator/Constraints/NoLockoutValidator.php index 7d7a3588..9d51d81e 100644 --- a/src/Validator/Constraints/NoLockoutValidator.php +++ b/src/Validator/Constraints/NoLockoutValidator.php @@ -34,11 +34,8 @@ use Symfony\Component\Validator\ConstraintValidator; class NoLockoutValidator extends ConstraintValidator { - protected array $perm_structure; - public function __construct(protected PermissionManager $resolver, protected Security $security, protected EntityManagerInterface $entityManager) { - $this->perm_structure = $resolver->getPermissionStructure(); } /** @@ -71,6 +68,8 @@ class NoLockoutValidator extends ConstraintValidator ) ?? false)) { $this->context->addViolation($constraint->message); } + } else { + throw new \LogicException('The NoLockout constraint can only be used on User or Group objects.'); } } } diff --git a/src/Validator/Constraints/NoneOfItsChildren.php b/src/Validator/Constraints/NoneOfItsChildren.php index b8e92faa..8f1e059a 100644 --- a/src/Validator/Constraints/NoneOfItsChildren.php +++ b/src/Validator/Constraints/NoneOfItsChildren.php @@ -27,9 +27,8 @@ use Symfony\Component\Validator\Constraint; /** * Constraints the parent property on StructuralDBElement objects in the way, that neither the object self nor any * of its children can be assigned. - * - * @Annotation */ +#[\Attribute(\Attribute::TARGET_PROPERTY)] class NoneOfItsChildren extends Constraint { /** diff --git a/src/Validator/Constraints/ProjectSystem/ValidProjectBuildRequest.php b/src/Validator/Constraints/ProjectSystem/ValidProjectBuildRequest.php index 05ed48e9..1e9ac834 100644 --- a/src/Validator/Constraints/ProjectSystem/ValidProjectBuildRequest.php +++ b/src/Validator/Constraints/ProjectSystem/ValidProjectBuildRequest.php @@ -26,9 +26,8 @@ use Symfony\Component\Validator\Constraint; /** * This constraint checks that the given ProjectBuildRequest is valid. - * - * @Annotation */ +#[\Attribute(\Attribute::TARGET_CLASS)] class ValidProjectBuildRequest extends Constraint { public function getTargets(): string diff --git a/src/Validator/Constraints/Selectable.php b/src/Validator/Constraints/Selectable.php index 20a51aad..f65cb685 100644 --- a/src/Validator/Constraints/Selectable.php +++ b/src/Validator/Constraints/Selectable.php @@ -27,9 +27,8 @@ use Symfony\Component\Validator\Constraint; /** * If a property is marked with this constraint, the choosen value (of type StructuralDBElement) * must NOT be marked as not selectable. - * - * @Annotation */ +#[\Attribute(\Attribute::TARGET_PROPERTY)] class Selectable extends Constraint { public $message = 'validator.isSelectable'; diff --git a/src/Validator/Constraints/UrlOrBuiltin.php b/src/Validator/Constraints/UrlOrBuiltin.php index 20b71871..ceec5d07 100644 --- a/src/Validator/Constraints/UrlOrBuiltin.php +++ b/src/Validator/Constraints/UrlOrBuiltin.php @@ -27,9 +27,8 @@ use Symfony\Component\Validator\Constraints\Url; /** * Constraints the field that way that the content is either an url or a path to a builtin ressource (like %FOOTPRINTS%). - * - * @Annotation */ +#[\Attribute(\Attribute::TARGET_PROPERTY)] class UrlOrBuiltin extends Url { /** diff --git a/src/Validator/Constraints/ValidFileFilter.php b/src/Validator/Constraints/ValidFileFilter.php index 8a7b70d0..756e6a37 100644 --- a/src/Validator/Constraints/ValidFileFilter.php +++ b/src/Validator/Constraints/ValidFileFilter.php @@ -27,6 +27,7 @@ use Symfony\Component\Validator\Constraint; /** * @Annotation */ +#[\Attribute(\Attribute::TARGET_PROPERTY)] class ValidFileFilter extends Constraint { } diff --git a/src/Validator/Constraints/ValidPartLot.php b/src/Validator/Constraints/ValidPartLot.php index 3b9658ac..a82c6a10 100644 --- a/src/Validator/Constraints/ValidPartLot.php +++ b/src/Validator/Constraints/ValidPartLot.php @@ -27,9 +27,8 @@ use Symfony\Component\Validator\Constraint; /** * A constraint "dummy" to validate the PartLot. * We need to access services in our Validator, so we can not use a simple callback on PartLot. - * - * @Annotation */ +#[\Attribute(\Attribute::TARGET_CLASS)] class ValidPartLot extends Constraint { public function getTargets(): string diff --git a/src/Validator/Constraints/ValidPermission.php b/src/Validator/Constraints/ValidPermission.php index 58a4ad2c..4d05f6cf 100644 --- a/src/Validator/Constraints/ValidPermission.php +++ b/src/Validator/Constraints/ValidPermission.php @@ -28,8 +28,8 @@ use Symfony\Component\Validator\Constraint; * A PermissionEmbed object with this annotation will be checked with ValidPermissionValidator. * That means the alsoSet values of the permission operations are set. * - * @Annotation */ +#[\Attribute(\Attribute::TARGET_PROPERTY)] class ValidPermission extends Constraint { } diff --git a/src/Validator/Constraints/ValidTheme.php b/src/Validator/Constraints/ValidTheme.php index 03e0d35b..92a19f5a 100644 --- a/src/Validator/Constraints/ValidTheme.php +++ b/src/Validator/Constraints/ValidTheme.php @@ -26,8 +26,8 @@ use Symfony\Component\Validator\Constraint; /** * A constraint to validate the theme setting of the user. - * @Annotation */ +#[\Attribute(\Attribute::TARGET_PROPERTY)] class ValidTheme extends Constraint { public string $message = 'validator.selected_theme_is_invalid';