NumberConstraintTrait.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Validator\Constraints;
  11. use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
  12. trigger_deprecation('symfony/validator', '5.2', '%s is deprecated.', NumberConstraintTrait::class);
  13. /**
  14. * @author Jan Schädlich <jan.schaedlich@sensiolabs.de>
  15. *
  16. * @deprecated since Symfony 5.2
  17. */
  18. trait NumberConstraintTrait
  19. {
  20. private function configureNumberConstraintOptions($options): array
  21. {
  22. if (null === $options) {
  23. $options = [];
  24. } elseif (!\is_array($options)) {
  25. $options = [$this->getDefaultOption() => $options];
  26. }
  27. if (isset($options['propertyPath'])) {
  28. throw new ConstraintDefinitionException(sprintf('The "propertyPath" option of the "%s" constraint cannot be set.', static::class));
  29. }
  30. if (isset($options['value'])) {
  31. throw new ConstraintDefinitionException(sprintf('The "value" option of the "%s" constraint cannot be set.', static::class));
  32. }
  33. $options['value'] = 0;
  34. return $options;
  35. }
  36. }