88use AssoConnect \ValidatorBundle \Validator \ConstraintsSetProvider \Field \FieldConstraintsSetProviderInterface ;
99use Doctrine \ORM \EntityManagerInterface ;
1010use Doctrine \ORM \Mapping \ClassMetadataInfo ;
11+ use Doctrine \ORM \Mapping \FieldMapping ;
1112use Symfony \Component \PropertyAccess \Exception \UnexpectedTypeException ;
1213use Symfony \Component \PropertyAccess \PropertyAccess ;
1314use Symfony \Component \Validator \Constraint ;
@@ -79,13 +80,12 @@ public function validate(mixed $entity, Constraint $constraint): void
7980 }
8081
8182 /**
82- * @param FieldMapping $fieldMapping
8383 * @return Constraint[]
8484 */
85- public function getConstraintsForType (array $ fieldMapping ): array
85+ public function getConstraintsForType (FieldMapping $ fieldMapping ): array
8686 {
8787 foreach ($ this ->fieldConstraintsSetFactories as $ fieldConstraintsSetProvider ) {
88- if ($ fieldConstraintsSetProvider ->supports ($ fieldMapping[ ' type ' ] )) {
88+ if ($ fieldConstraintsSetProvider ->supports ($ fieldMapping-> type )) {
8989 return $ fieldConstraintsSetProvider ->getConstraints ($ fieldMapping );
9090 }
9191 }
@@ -105,9 +105,7 @@ public function getConstraints(string $class, string $field): array
105105 if (array_key_exists ($ field , $ metadata ->fieldMappings )) {
106106 $ fieldMapping = $ metadata ->fieldMappings [$ field ];
107107
108- // Nullable field
109- Assert::keyExists ($ fieldMapping , 'nullable ' );
110- if (true !== $ fieldMapping ['nullable ' ]) {
108+ if (true !== $ fieldMapping ->nullable ) {
111109 $ constraints [] = [new NotNull ()];
112110 }
113111
0 commit comments