Skip to content

Commit 40ed115

Browse files
committed
include file and line number in deprecation
1 parent dc77aa4 commit 40ed115

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Loader/YamlFileLoader.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,18 @@ public function load($file, $type = null)
5858
$this->yamlParser = new YamlParser();
5959
}
6060

61+
$prevErrorHandler = set_error_handler(function ($level, $message, $script, $line) use ($file, &$prevErrorHandler) {
62+
$message = E_USER_DEPRECATED === $level ? preg_replace('/ on line \d+/', ' in "'.$file.'"$0', $message) : $message;
63+
64+
return $prevErrorHandler ? $prevErrorHandler($level, $message, $script, $line) : false;
65+
});
66+
6167
try {
6268
$parsedConfig = $this->yamlParser->parse(file_get_contents($path), Yaml::PARSE_KEYS_AS_STRINGS);
6369
} catch (ParseException $e) {
6470
throw new \InvalidArgumentException(sprintf('The file "%s" does not contain valid YAML.', $path), 0, $e);
71+
} finally {
72+
restore_error_handler();
6573
}
6674

6775
$collection = new RouteCollection();

0 commit comments

Comments
 (0)