Mercurial > hg > isophonics-drupal-site
comparison vendor/symfony/validator/Mapping/Loader/YamlFileLoader.php @ 14:1fec387a4317
Update Drupal core to 8.5.2 via Composer
author | Chris Cannam |
---|---|
date | Mon, 23 Apr 2018 09:46:53 +0100 |
parents | 4c8ae668cc8c |
children | 129ea1e6d783 |
comparison
equal
deleted
inserted
replaced
13:5fb285c0d0e3 | 14:1fec387a4317 |
---|---|
12 namespace Symfony\Component\Validator\Mapping\Loader; | 12 namespace Symfony\Component\Validator\Mapping\Loader; |
13 | 13 |
14 use Symfony\Component\Validator\Mapping\ClassMetadata; | 14 use Symfony\Component\Validator\Mapping\ClassMetadata; |
15 use Symfony\Component\Yaml\Exception\ParseException; | 15 use Symfony\Component\Yaml\Exception\ParseException; |
16 use Symfony\Component\Yaml\Parser as YamlParser; | 16 use Symfony\Component\Yaml\Parser as YamlParser; |
17 use Symfony\Component\Yaml\Yaml; | |
17 | 18 |
18 /** | 19 /** |
19 * Loads validation metadata from a YAML file. | 20 * Loads validation metadata from a YAML file. |
20 * | 21 * |
21 * @author Bernhard Schussek <bschussek@gmail.com> | 22 * @author Bernhard Schussek <bschussek@gmail.com> |
112 * @throws \InvalidArgumentException If the file could not be loaded or did | 113 * @throws \InvalidArgumentException If the file could not be loaded or did |
113 * not contain a YAML array | 114 * not contain a YAML array |
114 */ | 115 */ |
115 private function parseFile($path) | 116 private function parseFile($path) |
116 { | 117 { |
118 $prevErrorHandler = set_error_handler(function ($level, $message, $script, $line) use ($path, &$prevErrorHandler) { | |
119 $message = E_USER_DEPRECATED === $level ? preg_replace('/ on line \d+/', ' in "'.$path.'"$0', $message) : $message; | |
120 | |
121 return $prevErrorHandler ? $prevErrorHandler($level, $message, $script, $line) : false; | |
122 }); | |
123 | |
117 try { | 124 try { |
118 $classes = $this->yamlParser->parse(file_get_contents($path)); | 125 $classes = $this->yamlParser->parseFile($path, Yaml::PARSE_CONSTANT); |
119 } catch (ParseException $e) { | 126 } catch (ParseException $e) { |
120 throw new \InvalidArgumentException(sprintf('The file "%s" does not contain valid YAML.', $path), 0, $e); | 127 throw new \InvalidArgumentException(sprintf('The file "%s" does not contain valid YAML.', $path), 0, $e); |
128 } finally { | |
129 restore_error_handler(); | |
121 } | 130 } |
122 | 131 |
123 // empty file | 132 // empty file |
124 if (null === $classes) { | 133 if (null === $classes) { |
125 return array(); | 134 return array(); |