Skip to content

Commit 6a4b2b4

Browse files
committed
Merge branch '6.2' into 6.3
* 6.2: fix Doctrine deprecations fix merge Fix Doctrine deprecations [Validator] Remove internal from methods on non-internal interfaces [PhpUnitBridge] Fix support for the NO_COLOR env var
2 parents b18c05b + 1f85015 commit 6a4b2b4

File tree

3 files changed

+39
-37
lines changed

3 files changed

+39
-37
lines changed

Context/ExecutionContextInterface.php

Lines changed: 9 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -119,96 +119,75 @@ public function getValidator(): ValidatorInterface;
119119
public function getObject(): ?object;
120120

121121
/**
122-
* Sets the currently validated value.
122+
* Warning: Should not be called by user code, to be used by the validator engine only.
123123
*
124124
* @param object|null $object The currently validated object
125125
* @param string $propertyPath The property path to the current value
126-
*
127-
* @internal Used by the validator engine. Should not be called by user
128-
* code.
129126
*/
130127
public function setNode(mixed $value, ?object $object, MetadataInterface $metadata = null, string $propertyPath): void;
131128

132129
/**
133-
* Sets the currently validated group.
130+
* Warning: Should not be called by user code, to be used by the validator engine only.
134131
*
135132
* @param string|null $group The validated group
136-
*
137-
* @internal Used by the validator engine. Should not be called by user
138-
* code.
139133
*/
140134
public function setGroup(?string $group): void;
141135

142136
/**
143-
* Sets the currently validated constraint.
144-
*
145-
* @internal Used by the validator engine. Should not be called by user
146-
* code.
137+
* Warning: Should not be called by user code, to be used by the validator engine only.
147138
*/
148139
public function setConstraint(Constraint $constraint): void;
149140

150141
/**
151-
* Marks an object as validated in a specific validation group.
142+
* Warning: Should not be called by user code, to be used by the validator engine only.
152143
*
153144
* @param string $cacheKey The hash of the object
154145
* @param string $groupHash The group's name or hash, if it is group
155146
* sequence
156-
*
157-
* @internal Used by the validator engine. Should not be called by user
158-
* code.
159147
*/
160148
public function markGroupAsValidated(string $cacheKey, string $groupHash): void;
161149

162150
/**
163-
* Returns whether an object was validated in a specific validation group.
151+
* Warning: Should not be called by user code, to be used by the validator engine only.
164152
*
165153
* @param string $cacheKey The hash of the object
166154
* @param string $groupHash The group's name or hash, if it is group
167155
* sequence
168156
*
169-
* @internal Used by the validator engine
170157
*/
171158
public function isGroupValidated(string $cacheKey, string $groupHash): bool;
172159

173160
/**
174-
* Marks a constraint as validated for an object.
161+
* Warning: Should not be called by user code, to be used by the validator engine only.
175162
*
176163
* @param string $cacheKey The hash of the object
177164
* @param string $constraintHash The hash of the constraint
178-
*
179-
* @internal Used by the validator engine. Should not be called by user
180-
* code.
181165
*/
182166
public function markConstraintAsValidated(string $cacheKey, string $constraintHash): void;
183167

184168
/**
185-
* Returns whether a constraint was validated for an object.
169+
* Warning: Should not be called by user code, to be used by the validator engine only.
186170
*
187171
* @param string $cacheKey The hash of the object
188172
* @param string $constraintHash The hash of the constraint
189173
*
190-
* @internal Used by the validator engine
191174
*/
192175
public function isConstraintValidated(string $cacheKey, string $constraintHash): bool;
193176

194177
/**
195-
* Marks that an object was initialized.
178+
* Warning: Should not be called by user code, to be used by the validator engine only.
196179
*
197180
* @param string $cacheKey The hash of the object
198181
*
199-
* @internal Used by the validator engine. Should not be called by user
200-
* code.
201-
*
202182
* @see ObjectInitializerInterface
203183
*/
204184
public function markObjectAsInitialized(string $cacheKey): void;
205185

206186
/**
207-
* Returns whether an object was initialized.
187+
* Warning: Should not be called by user code, to be used by the validator engine only.
208188
*
209189
* @param string $cacheKey The hash of the object
210190
*
211-
* @internal Used by the validator engine
212191
*
213192
* @see ObjectInitializerInterface
214193
*/

Mapping/ClassMetadata.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -346,16 +346,17 @@ public function mergeConstraints(self $source)
346346
$constraint->addImplicitGroupName($this->getDefaultGroup());
347347
}
348348

349-
$this->addPropertyMetadata($member);
350-
351349
if ($member instanceof MemberMetadata && !$member->isPrivate($this->name)) {
352350
$property = $member->getPropertyName();
351+
$this->members[$property] = [$member];
353352

354-
if ($member instanceof PropertyMetadata && !isset($this->properties[$property])) {
353+
if ($member instanceof PropertyMetadata) {
355354
$this->properties[$property] = $member;
356-
} elseif ($member instanceof GetterMetadata && !isset($this->getters[$property])) {
355+
} elseif ($member instanceof GetterMetadata) {
357356
$this->getters[$property] = $member;
358357
}
358+
} else {
359+
$this->addPropertyMetadata($member);
359360
}
360361
}
361362
}

Mapping/Loader/AnnotationLoader.php

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,27 +92,49 @@ public function loadClassMetadata(ClassMetadata $metadata): bool
9292
*/
9393
private function getAnnotations(object $reflection): iterable
9494
{
95+
$dedup = [];
96+
9597
foreach ($reflection->getAttributes(GroupSequence::class) as $attribute) {
98+
$dedup[] = $attribute->newInstance();
9699
yield $attribute->newInstance();
97100
}
98101
foreach ($reflection->getAttributes(GroupSequenceProvider::class) as $attribute) {
102+
$dedup[] = $attribute->newInstance();
99103
yield $attribute->newInstance();
100104
}
101105
foreach ($reflection->getAttributes(Constraint::class, \ReflectionAttribute::IS_INSTANCEOF) as $attribute) {
106+
$dedup[] = $attribute->newInstance();
102107
yield $attribute->newInstance();
103108
}
104109
if (!$this->reader) {
105110
return;
106111
}
107112

113+
$annotations = [];
114+
108115
if ($reflection instanceof \ReflectionClass) {
109-
yield from $this->reader->getClassAnnotations($reflection);
116+
$annotations = $this->reader->getClassAnnotations($reflection);
110117
}
111118
if ($reflection instanceof \ReflectionMethod) {
112-
yield from $this->reader->getMethodAnnotations($reflection);
119+
$annotations = $this->reader->getMethodAnnotations($reflection);
113120
}
114121
if ($reflection instanceof \ReflectionProperty) {
115-
yield from $this->reader->getPropertyAnnotations($reflection);
122+
$annotations = $this->reader->getPropertyAnnotations($reflection);
123+
}
124+
125+
foreach ($dedup as $annotation) {
126+
if ($annotation instanceof Constraint) {
127+
$annotation->groups; // trigger initialization of the "groups" property
128+
}
129+
}
130+
131+
foreach ($annotations as $annotation) {
132+
if ($annotation instanceof Constraint) {
133+
$annotation->groups; // trigger initialization of the "groups" property
134+
}
135+
if (!\in_array($annotation, $dedup, false)) {
136+
yield $annotation;
137+
}
116138
}
117139
}
118140
}

0 commit comments

Comments
 (0)