From 9b4206ff73373ce017d633e2be6ade69e869d4b0 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Tue, 4 Apr 2017 15:06:55 +0200 Subject: [PATCH] report deprecations when linting YAML files --- src/Symfony/Component/Yaml/Command/LintCommand.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Symfony/Component/Yaml/Command/LintCommand.php b/src/Symfony/Component/Yaml/Command/LintCommand.php index ea86a1f8c1..48f6d94a03 100644 --- a/src/Symfony/Component/Yaml/Command/LintCommand.php +++ b/src/Symfony/Component/Yaml/Command/LintCommand.php @@ -102,10 +102,20 @@ EOF private function validate($content, $file = null) { + $prevErrorHandler = set_error_handler(function ($level, $message, $file, $line) use (&$prevErrorHandler) { + if (E_USER_DEPRECATED === $level) { + throw new ParseException($message); + } + + return $prevErrorHandler ? $prevErrorHandler($level, $message, $file, $line) : false; + }); + try { $this->getParser()->parse($content); } catch (ParseException $e) { return array('file' => $file, 'valid' => false, 'message' => $e->getMessage()); + } finally { + restore_error_handler(); } return array('file' => $file, 'valid' => true);