Skip to content

Commit e4059e1

Browse files
committed
Merge branch '3.3' into 3.4
* 3.3: include file and line number in deprecation parse merge keys with PARSE_OBJECT_FOR_MAP flag
2 parents c5fb3a2 + 1d835bf commit e4059e1

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Mapping/Loader/YamlFileLoader.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,18 @@ protected function parseNodes(array $nodes)
115115
*/
116116
private function parseFile($path)
117117
{
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+
118124
try {
119125
$classes = $this->yamlParser->parseFile($path, Yaml::PARSE_CONSTANT);
120126
} catch (ParseException $e) {
121127
throw new \InvalidArgumentException(sprintf('The file "%s" does not contain valid YAML.', $path), 0, $e);
128+
} finally {
129+
restore_error_handler();
122130
}
123131

124132
// empty file

0 commit comments

Comments
 (0)