mirror of
https://github.com/symfony/validator.git
synced 2026-03-24 01:12:13 +01:00
42 lines
1.3 KiB
PHP
42 lines
1.3 KiB
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of the Symfony package.
|
|
*
|
|
* (c) Fabien Potencier <fabien@symfony.com>
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Symfony\Component\Validator\Constraints;
|
|
|
|
use Symfony\Component\Validator\Constraint;
|
|
use Symfony\Component\Validator\Exception\InvalidArgumentException;
|
|
|
|
/**
|
|
* Enables auto mapping.
|
|
*
|
|
* Using the attribute on a property has higher precedence than using it on a class,
|
|
* which has higher precedence than any configuration that might be defined outside the class.
|
|
*
|
|
* @author Kévin Dunglas <dunglas@gmail.com>
|
|
*/
|
|
#[\Attribute(\Attribute::TARGET_PROPERTY | \Attribute::TARGET_METHOD | \Attribute::TARGET_CLASS)]
|
|
class EnableAutoMapping extends Constraint
|
|
{
|
|
public function __construct(?array $options = null, mixed $payload = null)
|
|
{
|
|
if (null !== $options) {
|
|
throw new InvalidArgumentException(\sprintf('Passing an array of options to configure the "%s" constraint is no longer supported.', static::class));
|
|
}
|
|
|
|
parent::__construct(null, null, $payload);
|
|
}
|
|
|
|
public function getTargets(): string|array
|
|
{
|
|
return [self::PROPERTY_CONSTRAINT, self::CLASS_CONSTRAINT];
|
|
}
|
|
}
|