Mercurial > hg > isophonics-drupal-site
comparison vendor/symfony/validator/Mapping/Loader/YamlFileLoader.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 |
---|---|
78 * | 78 * |
79 * @return array An array of values or Constraint instances | 79 * @return array An array of values or Constraint instances |
80 */ | 80 */ |
81 protected function parseNodes(array $nodes) | 81 protected function parseNodes(array $nodes) |
82 { | 82 { |
83 $values = array(); | 83 $values = []; |
84 | 84 |
85 foreach ($nodes as $name => $childNodes) { | 85 foreach ($nodes as $name => $childNodes) { |
86 if (is_numeric($name) && is_array($childNodes) && 1 === count($childNodes)) { | 86 if (is_numeric($name) && \is_array($childNodes) && 1 === \count($childNodes)) { |
87 $options = current($childNodes); | 87 $options = current($childNodes); |
88 | 88 |
89 if (is_array($options)) { | 89 if (\is_array($options)) { |
90 $options = $this->parseNodes($options); | 90 $options = $this->parseNodes($options); |
91 } | 91 } |
92 | 92 |
93 $values[] = $this->newConstraint(key($childNodes), $options); | 93 $values[] = $this->newConstraint(key($childNodes), $options); |
94 } else { | 94 } else { |
95 if (is_array($childNodes)) { | 95 if (\is_array($childNodes)) { |
96 $childNodes = $this->parseNodes($childNodes); | 96 $childNodes = $this->parseNodes($childNodes); |
97 } | 97 } |
98 | 98 |
99 $values[$name] = $childNodes; | 99 $values[$name] = $childNodes; |
100 } | 100 } |
129 restore_error_handler(); | 129 restore_error_handler(); |
130 } | 130 } |
131 | 131 |
132 // empty file | 132 // empty file |
133 if (null === $classes) { | 133 if (null === $classes) { |
134 return array(); | 134 return []; |
135 } | 135 } |
136 | 136 |
137 // not an array | 137 // not an array |
138 if (!is_array($classes)) { | 138 if (!\is_array($classes)) { |
139 throw new \InvalidArgumentException(sprintf('The file "%s" must contain a YAML array.', $this->file)); | 139 throw new \InvalidArgumentException(sprintf('The file "%s" must contain a YAML array.', $this->file)); |
140 } | 140 } |
141 | 141 |
142 return $classes; | 142 return $classes; |
143 } | 143 } |
169 | 169 |
170 if (isset($classDescription['group_sequence'])) { | 170 if (isset($classDescription['group_sequence'])) { |
171 $metadata->setGroupSequence($classDescription['group_sequence']); | 171 $metadata->setGroupSequence($classDescription['group_sequence']); |
172 } | 172 } |
173 | 173 |
174 if (isset($classDescription['constraints']) && is_array($classDescription['constraints'])) { | 174 if (isset($classDescription['constraints']) && \is_array($classDescription['constraints'])) { |
175 foreach ($this->parseNodes($classDescription['constraints']) as $constraint) { | 175 foreach ($this->parseNodes($classDescription['constraints']) as $constraint) { |
176 $metadata->addConstraint($constraint); | 176 $metadata->addConstraint($constraint); |
177 } | 177 } |
178 } | 178 } |
179 | 179 |
180 if (isset($classDescription['properties']) && is_array($classDescription['properties'])) { | 180 if (isset($classDescription['properties']) && \is_array($classDescription['properties'])) { |
181 foreach ($classDescription['properties'] as $property => $constraints) { | 181 foreach ($classDescription['properties'] as $property => $constraints) { |
182 if (null !== $constraints) { | 182 if (null !== $constraints) { |
183 foreach ($this->parseNodes($constraints) as $constraint) { | 183 foreach ($this->parseNodes($constraints) as $constraint) { |
184 $metadata->addPropertyConstraint($property, $constraint); | 184 $metadata->addPropertyConstraint($property, $constraint); |
185 } | 185 } |
186 } | 186 } |
187 } | 187 } |
188 } | 188 } |
189 | 189 |
190 if (isset($classDescription['getters']) && is_array($classDescription['getters'])) { | 190 if (isset($classDescription['getters']) && \is_array($classDescription['getters'])) { |
191 foreach ($classDescription['getters'] as $getter => $constraints) { | 191 foreach ($classDescription['getters'] as $getter => $constraints) { |
192 if (null !== $constraints) { | 192 if (null !== $constraints) { |
193 foreach ($this->parseNodes($constraints) as $constraint) { | 193 foreach ($this->parseNodes($constraints) as $constraint) { |
194 $metadata->addGetterConstraint($getter, $constraint); | 194 $metadata->addGetterConstraint($getter, $constraint); |
195 } | 195 } |