4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Validator\Constraints;
14 use Symfony\Component\Validator\Constraint;
18 * @Target({"CLASS", "PROPERTY", "METHOD", "ANNOTATION"})
20 * @author Bernhard Schussek <bschussek@gmail.com>
22 class Callback extends Constraint
25 * @var string|callable
32 * @deprecated since version 2.4, to be removed in 3.0.
39 public function __construct($options = null)
41 // Invocation through annotations with an array parameter only
42 if (is_array($options) && 1 === count($options) && isset($options['value'])) {
43 $options = $options['value'];
46 if (is_array($options) && isset($options['methods'])) {
47 @trigger_error('The "methods" option of the '.__CLASS__.' class is deprecated since version 2.4 and will be removed in 3.0. Use the "callback" option instead.', E_USER_DEPRECATED);
50 if (is_array($options) && !isset($options['callback']) && !isset($options['methods']) && !isset($options['groups']) && !isset($options['payload'])) {
51 if (is_callable($options) || !$options) {
52 $options = array('callback' => $options);
54 // @deprecated, to be removed in 3.0
55 $options = array('methods' => $options);
59 parent::__construct($options);
65 public function getDefaultOption()
73 public function getTargets()
75 return array(self::CLASS_CONSTRAINT, self::PROPERTY_CONSTRAINT);