Skip to content

Commit 1f85015

Browse files
Merge branch '5.4' into 6.2
* 5.4: Fix Doctrine deprecations [Validator] Remove internal from methods on non-internal interfaces [PhpUnitBridge] Fix support for the NO_COLOR env var
2 parents 14998e4 + 25ca8e5 commit 1f85015

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
@@ -117,96 +117,75 @@ public function getValidator(): ValidatorInterface;
117117
public function getObject(): ?object;
118118

119119
/**
120-
* Sets the currently validated value.
120+
* Warning: Should not be called by user code, to be used by the validator engine only.
121121
*
122122
* @param object|null $object The currently validated object
123123
* @param string $propertyPath The property path to the current value
124-
*
125-
* @internal Used by the validator engine. Should not be called by user
126-
* code.
127124
*/
128125
public function setNode(mixed $value, ?object $object, MetadataInterface $metadata = null, string $propertyPath);
129126

130127
/**
131-
* Sets the currently validated group.
128+
* Warning: Should not be called by user code, to be used by the validator engine only.
132129
*
133130
* @param string|null $group The validated group
134-
*
135-
* @internal Used by the validator engine. Should not be called by user
136-
* code.
137131
*/
138132
public function setGroup(?string $group);
139133

140134
/**
141-
* Sets the currently validated constraint.
142-
*
143-
* @internal Used by the validator engine. Should not be called by user
144-
* code.
135+
* Warning: Should not be called by user code, to be used by the validator engine only.
145136
*/
146137
public function setConstraint(Constraint $constraint);
147138

148139
/**
149-
* Marks an object as validated in a specific validation group.
140+
* Warning: Should not be called by user code, to be used by the validator engine only.
150141
*
151142
* @param string $cacheKey The hash of the object
152143
* @param string $groupHash The group's name or hash, if it is group
153144
* sequence
154-
*
155-
* @internal Used by the validator engine. Should not be called by user
156-
* code.
157145
*/
158146
public function markGroupAsValidated(string $cacheKey, string $groupHash);
159147

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

171158
/**
172-
* Marks a constraint as validated for an object.
159+
* Warning: Should not be called by user code, to be used by the validator engine only.
173160
*
174161
* @param string $cacheKey The hash of the object
175162
* @param string $constraintHash The hash of the constraint
176-
*
177-
* @internal Used by the validator engine. Should not be called by user
178-
* code.
179163
*/
180164
public function markConstraintAsValidated(string $cacheKey, string $constraintHash);
181165

182166
/**
183-
* Returns whether a constraint was validated for an object.
167+
* Warning: Should not be called by user code, to be used by the validator engine only.
184168
*
185169
* @param string $cacheKey The hash of the object
186170
* @param string $constraintHash The hash of the constraint
187171
*
188-
* @internal Used by the validator engine
189172
*/
190173
public function isConstraintValidated(string $cacheKey, string $constraintHash): bool;
191174

192175
/**
193-
* Marks that an object was initialized.
176+
* Warning: Should not be called by user code, to be used by the validator engine only.
194177
*
195178
* @param string $cacheKey The hash of the object
196179
*
197-
* @internal Used by the validator engine. Should not be called by user
198-
* code.
199-
*
200180
* @see ObjectInitializerInterface
201181
*/
202182
public function markObjectAsInitialized(string $cacheKey);
203183

204184
/**
205-
* Returns whether an object was initialized.
185+
* Warning: Should not be called by user code, to be used by the validator engine only.
206186
*
207187
* @param string $cacheKey The hash of the object
208188
*
209-
* @internal Used by the validator engine
210189
*
211190
* @see ObjectInitializerInterface
212191
*/

Mapping/ClassMetadata.php

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

343-
$this->addPropertyMetadata($member);
344-
345343
if ($member instanceof MemberMetadata && !$member->isPrivate($this->name)) {
346344
$property = $member->getPropertyName();
345+
$this->members[$property] = [$member];
347346

348-
if ($member instanceof PropertyMetadata && !isset($this->properties[$property])) {
347+
if ($member instanceof PropertyMetadata) {
349348
$this->properties[$property] = $member;
350-
} elseif ($member instanceof GetterMetadata && !isset($this->getters[$property])) {
349+
} elseif ($member instanceof GetterMetadata) {
351350
$this->getters[$property] = $member;
352351
}
352+
} else {
353+
$this->addPropertyMetadata($member);
353354
}
354355
}
355356
}

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)