Deprecated: Constant E_STRICT is deprecated in /home/pastorz/old-espace-client/vendor/symfony/error-handler/ErrorHandler.php on line 58
Deprecated: Constant E_STRICT is deprecated in /home/pastorz/old-espace-client/vendor/symfony/error-handler/ErrorHandler.php on line 76 Symfony Profiler
vendor/symfony/validator/ValidatorBuilder.php line 395
public function enableAnnotationMapping(/* bool $skipDoctrineAnnotations = true */)
{
if (null !== $this->metadataFactory) {
throw new ValidatorException('You cannot enable annotation mapping after setting a custom metadata factory. Configure your metadata factory instead.');
if (false === $skipDoctrineAnnotations || null === $skipDoctrineAnnotations) {
trigger_deprecation('symfony/validator', '5.2', 'Not passing true as first argument to "%s" is deprecated. Pass true and call "addDefaultDoctrineAnnotationReader()" if you want to enable annotation mapping with Doctrine Annotations.', __METHOD__);
trigger_deprecation('symfony/validator', '5.2', 'Passing an instance of "%s" as first argument to "%s" is deprecated. Pass true instead and call setDoctrineAnnotationReader() if you want to enable annotation mapping with Doctrine Annotations.', get_debug_type($skipDoctrineAnnotations), __METHOD__);
throw new ValidatorException('You cannot set a custom metadata factory after adding custom mappings. You should do either of both.');
}
$this->metadataFactory = $metadataFactory;
return $this;
}
/**
* Sets the cache for caching class metadata.
*
* @return $this
*/
public function setMappingCache(CacheItemPoolInterface $cache)
{
if (null !== $this->metadataFactory) {
throw new ValidatorException('You cannot set a custom mapping cache after setting a custom metadata factory. Configure your metadata factory instead.');
}
$this->mappingCache = $cache;
return $this;
}
/**
* Sets the constraint validator factory used by the validator.
*
* @return $this
*/
public function setConstraintValidatorFactory(ConstraintValidatorFactoryInterface $validatorFactory)
{
$this->validatorFactory = $validatorFactory;
return $this;
}
/**
* Sets the translator used for translating violation messages.
*
* @return $this
*/
public function setTranslator(TranslatorInterface $translator)
{
$this->translator = $translator;
return $this;
}
/**
* Sets the default translation domain of violation messages.
*
* The same message can have different translations in different domains.
* Pass the domain that is used for violation messages by default to this
* method.
*
* @return $this
*/
public function setTranslationDomain(?string $translationDomain)
{
$this->translationDomain = $translationDomain;
return $this;
}
/**
* @return $this
*/
public function addLoader(LoaderInterface $loader)
{
$this->loaders[] = $loader;
return $this;
}
/**
* @return LoaderInterface[]
*/
public function getLoaders()
{
$loaders = [];
foreach ($this->xmlMappings as $xmlMapping) {
$loaders[] = new XmlFileLoader($xmlMapping);
}
foreach ($this->yamlMappings as $yamlMappings) {
$loaders[] = new YamlFileLoader($yamlMappings);
}
foreach ($this->methodMappings as $methodName) {
$loaders[] = new StaticMethodLoader($methodName);
}
if ($this->enableAnnotationMapping) {
$loaders[] = new AnnotationLoader($this->annotationReader);
}
return array_merge($loaders, $this->loaders);
}
/**
* Builds and returns a new validator object.
*
* @return ValidatorInterface
*/
public function getValidator()
{
$metadataFactory = $this->metadataFactory;
if (!$metadataFactory) {
$loaders = $this->getLoaders();
$loader = null;
if (\count($loaders) > 1) {
$loader = new LoaderChain($loaders);
} elseif (1 === \count($loaders)) {
$loader = $loaders[0];
}
$metadataFactory = new LazyLoadingMetadataFactory($loader, $this->mappingCache);
}
$validatorFactory = $this->validatorFactory ?? new ConstraintValidatorFactory();
$translator = $this->translator;
if (null === $translator) {
$translator = new class() implements TranslatorInterface, LocaleAwareInterface {
use TranslatorTrait;
};
// Force the locale to be 'en' when no translator is provided rather than relying on the Intl default locale
// This avoids depending on Intl or the stub implementation being available. It also ensures that Symfony
// validation messages are pluralized properly even when the default locale gets changed because they are in
// English.
$translator->setLocale('en');
}
$contextFactory = new ExecutionContextFactory($translator, $this->translationDomain);
return new RecursiveValidator($contextFactory, $metadataFactory, $validatorFactory, $this->initializers);
}
private function createAnnotationReader(): Reader
{
if (!class_exists(AnnotationReader::class)) {
throw new LogicException('Enabling annotation based constraint mapping requires the packages doctrine/annotations and symfony/cache to be installed.');
}
if (class_exists(ArrayAdapter::class)) {
return new PsrCachedReader(new AnnotationReader(), new ArrayAdapter());
}
if (class_exists(CachedReader::class) && class_exists(ArrayCache::class)) {
trigger_deprecation('symfony/validator', '5.4', 'Enabling annotation based constraint mapping without having symfony/cache installed is deprecated.');
return new CachedReader(new AnnotationReader(), new ArrayCache());
}
throw new LogicException('Enabling annotation based constraint mapping requires the packages doctrine/annotations and symfony/cache to be installed.');