s()->isInterface()) { return; } // Include constraints from the parent class if ($parent = $metadata->getReflectionClass()->getParentClass()) { $metadata->mergeConstraints($this->getMetadataFor($parent->name)); } // Include constraints from all directly implemented interfaces foreach ($metadata->getReflectionClass()->getInterfaces() as $interface) { if ('Symfony\Component\Validator\GroupSequenceProviderInterface' === $interface->name) { continue; } if ($parent && \in_array($interface->getName(), $parent->getInterfaceNames(), true)) { continue; } $metadata->mergeConstraints($this->getMetadataFor($interface->name)); } } /** * {@inheritdoc} */ public function hasMetadataFor($value) { if (!\is_object($value) && !\is_string($value)) { return false; } $class = ltrim(\is_object($value) ? \get_class($value) : $value, '\\'); return class_exists($class) || interface_exists($class, false); } /** * Replaces backslashes by dots in a class name. */ private function escapeClassName(string $class): string { if (str_contains($class, '@')) { // anonymous class: replace all PSR6-reserved characters return str_replace(["\0", '\\', '/', '@', ':', '{', '}', '(', ')'], '.', $class); } return str_replace('\\', '.', $class); } }