From 7af16f42cdf585e630c8262a6341b19ffb1a4b58 Mon Sep 17 00:00:00 2001 From: Jakub Vrana Date: Fri, 2 Dec 2011 16:55:02 -0800 Subject: [PATCH] Replace preg_quote() lint error by warning Summary: See http://php.net/regexp.reference.delimiters Test Plan: arc lint on a file with preg_quote() with one parameter Reviewers: epriestley Reviewed By: epriestley CC: aran, epriestley, vrana Differential Revision: https://secure.phabricator.com/D1163 --- src/lint/linter/xhpast/ArcanistXHPASTLinter.php | 7 +++++-- src/lint/linter/xhpast/__tests__/data/preg-quote.lint-test | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/lint/linter/xhpast/ArcanistXHPASTLinter.php b/src/lint/linter/xhpast/ArcanistXHPASTLinter.php index 87ba74a0..28b26811 100644 --- a/src/lint/linter/xhpast/ArcanistXHPASTLinter.php +++ b/src/lint/linter/xhpast/ArcanistXHPASTLinter.php @@ -91,6 +91,8 @@ class ArcanistXHPASTLinter extends ArcanistLinter { => ArcanistLintSeverity::SEVERITY_WARNING, self::LINT_NAMING_CONVENTIONS => ArcanistLintSeverity::SEVERITY_WARNING, + self::LINT_PREG_QUOTE_MISUSE + => ArcanistLintSeverity::SEVERITY_WARNING, ); } @@ -1054,8 +1056,9 @@ class ArcanistXHPASTLinter extends ArcanistLinter { /** * preg_quote() takes two arguments, but the second one is optional because - * PHP is awesome. If you don't pass a second argument, you're probably - * going to get something wrong. + * it is possible to use (), [] or {} as regular expression delimiters. If + * you don't pass a second argument, you're probably going to get something + * wrong. */ protected function lintPregQuote($root) { $function_calls = $root->selectDescendantsOfType('n_FUNCTION_CALL'); diff --git a/src/lint/linter/xhpast/__tests__/data/preg-quote.lint-test b/src/lint/linter/xhpast/__tests__/data/preg-quote.lint-test index 34e94996..66b3a275 100644 --- a/src/lint/linter/xhpast/__tests__/data/preg-quote.lint-test +++ b/src/lint/linter/xhpast/__tests__/data/preg-quote.lint-test @@ -8,5 +8,5 @@ function foo($bar) { } ~~~~~~~~~~ -error:4:3 Wrong number of arguments to preg_quote() -error:6:3 Wrong number of arguments to preg_quote() +warning:4:3 Wrong number of arguments to preg_quote() +warning:6:3 Wrong number of arguments to preg_quote()