function ClassMetadata::canCascade
1 call to ClassMetadata::canCascade()
- ClassMetadata::addConstraint in vendor/
symfony/ validator/ Mapping/ ClassMetadata.php - If the constraint {@link Cascade} is added, the cascading strategy will be changed to {@link CascadingStrategy::CASCADE}.
File
-
vendor/
symfony/ validator/ Mapping/ ClassMetadata.php, line 487
Class
- ClassMetadata
- Default implementation of {@link ClassMetadataInterface}.
Namespace
Symfony\Component\Validator\MappingCode
private function canCascade(?\ReflectionType $type = null) : bool {
if (null === $type) {
return false;
}
if ($type instanceof \ReflectionIntersectionType) {
foreach ($type->getTypes() as $nestedType) {
if ($this->canCascade($nestedType)) {
return true;
}
}
return false;
}
if ($type instanceof \ReflectionUnionType) {
foreach ($type->getTypes() as $nestedType) {
if (!$this->canCascade($nestedType)) {
return false;
}
}
return true;
}
return $type instanceof \ReflectionNamedType && (\in_array($type->getName(), [
'array',
'null',
], true) || class_exists($type->getName()));
}