Skip to content

Commit 305adfc

Browse files
committed
Merge branch '3.4'
* 3.4: include file and line number in deprecation parse merge keys with PARSE_OBJECT_FOR_MAP flag
2 parents 6975eed + fb65acc commit 305adfc

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
@@ -57,10 +57,18 @@ public function load($file, $type = null)
5757
$this->yamlParser = new YamlParser();
5858
}
5959

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

6674
$collection = new RouteCollection();

0 commit comments

Comments
 (0)