]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Replace preg_quote() lint error by warning
authorJakub Vrana <jakubv@fb.com>
Sat, 3 Dec 2011 00:55:02 +0000 (16:55 -0800)
committervrana <jakubv@fb.com>
Wed, 28 Dec 2011 21:09:42 +0000 (13:09 -0800)
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
src/lint/linter/xhpast/__tests__/data/preg-quote.lint-test

index 87ba74a02901e759a7c02cc0975d0c5436a58e16..28b26811c78e3776d131f50ce7ecae857533af80 100644 (file)
@@ -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');
index 34e949966b1b8cf280f5d7dd934d248886cad11f..66b3a2751eb7064101701360ea3606f1ffa996cf 100644 (file)
@@ -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()