comparison vendor/symfony/validator/Mapping/GenericMetadata.php @ 17:129ea1e6d783

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:21:36 +0000
parents 1fec387a4317
children
comparison
equal deleted inserted replaced
16:c2387f117808 17:129ea1e6d783
30 * 30 *
31 * @internal This property is public in order to reduce the size of the 31 * @internal This property is public in order to reduce the size of the
32 * class' serialized representation. Do not access it. Use 32 * class' serialized representation. Do not access it. Use
33 * {@link getConstraints()} and {@link findConstraints()} instead. 33 * {@link getConstraints()} and {@link findConstraints()} instead.
34 */ 34 */
35 public $constraints = array(); 35 public $constraints = [];
36 36
37 /** 37 /**
38 * @var array 38 * @var array
39 * 39 *
40 * @internal This property is public in order to reduce the size of the 40 * @internal This property is public in order to reduce the size of the
41 * class' serialized representation. Do not access it. Use 41 * class' serialized representation. Do not access it. Use
42 * {@link findConstraints()} instead. 42 * {@link findConstraints()} instead.
43 */ 43 */
44 public $constraintsByGroup = array(); 44 public $constraintsByGroup = [];
45 45
46 /** 46 /**
47 * The strategy for cascading objects. 47 * The strategy for cascading objects.
48 * 48 *
49 * By default, objects are not cascaded. 49 * By default, objects are not cascaded.
78 * 78 *
79 * @return string[] 79 * @return string[]
80 */ 80 */
81 public function __sleep() 81 public function __sleep()
82 { 82 {
83 return array( 83 return [
84 'constraints', 84 'constraints',
85 'constraintsByGroup', 85 'constraintsByGroup',
86 'cascadingStrategy', 86 'cascadingStrategy',
87 'traversalStrategy', 87 'traversalStrategy',
88 ); 88 ];
89 } 89 }
90 90
91 /** 91 /**
92 * Clones this object. 92 * Clones this object.
93 */ 93 */
94 public function __clone() 94 public function __clone()
95 { 95 {
96 $constraints = $this->constraints; 96 $constraints = $this->constraints;
97 97
98 $this->constraints = array(); 98 $this->constraints = [];
99 $this->constraintsByGroup = array(); 99 $this->constraintsByGroup = [];
100 100
101 foreach ($constraints as $constraint) { 101 foreach ($constraints as $constraint) {
102 $this->addConstraint(clone $constraint); 102 $this->addConstraint(clone $constraint);
103 } 103 }
104 } 104 }
120 * {@link Traverse} constraint 120 * {@link Traverse} constraint
121 */ 121 */
122 public function addConstraint(Constraint $constraint) 122 public function addConstraint(Constraint $constraint)
123 { 123 {
124 if ($constraint instanceof Traverse) { 124 if ($constraint instanceof Traverse) {
125 throw new ConstraintDefinitionException(sprintf( 125 throw new ConstraintDefinitionException(sprintf('The constraint "%s" can only be put on classes. Please use "Symfony\Component\Validator\Constraints\Valid" instead.', \get_class($constraint)));
126 'The constraint "%s" can only be put on classes. Please use '.
127 '"Symfony\Component\Validator\Constraints\Valid" instead.',
128 get_class($constraint)
129 ));
130 } 126 }
131 127
132 if ($constraint instanceof Valid && null === $constraint->groups) { 128 if ($constraint instanceof Valid && null === $constraint->groups) {
133 $this->cascadingStrategy = CascadingStrategy::CASCADE; 129 $this->cascadingStrategy = CascadingStrategy::CASCADE;
134 130
179 * 175 *
180 * @return bool 176 * @return bool
181 */ 177 */
182 public function hasConstraints() 178 public function hasConstraints()
183 { 179 {
184 return count($this->constraints) > 0; 180 return \count($this->constraints) > 0;
185 } 181 }
186 182
187 /** 183 /**
188 * {@inheritdoc} 184 * {@inheritdoc}
189 * 185 *
191 */ 187 */
192 public function findConstraints($group) 188 public function findConstraints($group)
193 { 189 {
194 return isset($this->constraintsByGroup[$group]) 190 return isset($this->constraintsByGroup[$group])
195 ? $this->constraintsByGroup[$group] 191 ? $this->constraintsByGroup[$group]
196 : array(); 192 : [];
197 } 193 }
198 194
199 /** 195 /**
200 * {@inheritdoc} 196 * {@inheritdoc}
201 */ 197 */