Fix bug in style changes for the Use cases on the live site.
[yaffs-website] / vendor / symfony / validator / Constraints / Callback.php
1 <?php
2
3 /*
4  * This file is part of the Symfony package.
5  *
6  * (c) Fabien Potencier <fabien@symfony.com>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11
12 namespace Symfony\Component\Validator\Constraints;
13
14 use Symfony\Component\Validator\Constraint;
15
16 /**
17  * @Annotation
18  * @Target({"CLASS", "PROPERTY", "METHOD", "ANNOTATION"})
19  *
20  * @author Bernhard Schussek <bschussek@gmail.com>
21  */
22 class Callback extends Constraint
23 {
24     /**
25      * @var string|callable
26      */
27     public $callback;
28
29     /**
30      * @var array
31      *
32      * @deprecated since version 2.4, to be removed in 3.0.
33      */
34     public $methods;
35
36     /**
37      * {@inheritdoc}
38      */
39     public function __construct($options = null)
40     {
41         // Invocation through annotations with an array parameter only
42         if (is_array($options) && 1 === count($options) && isset($options['value'])) {
43             $options = $options['value'];
44         }
45
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);
48         }
49
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);
53             } else {
54                 // @deprecated, to be removed in 3.0
55                 $options = array('methods' => $options);
56             }
57         }
58
59         parent::__construct($options);
60     }
61
62     /**
63      * {@inheritdoc}
64      */
65     public function getDefaultOption()
66     {
67         return 'callback';
68     }
69
70     /**
71      * {@inheritdoc}
72      */
73     public function getTargets()
74     {
75         return array(self::CLASS_CONSTRAINT, self::PROPERTY_CONSTRAINT);
76     }
77 }