From ba8beed447ff9662e42971318a0bffd92223fef7 Mon Sep 17 00:00:00 2001 From: Christopher Halbert Date: Tue, 18 Dec 2018 12:56:36 -0500 Subject: [PATCH] Add exclusion option. --- README.md | 10 ++++++++++ classes/options.php | 11 +++++++++-- composer.json | 5 ++++- mar.php | 3 +-- 4 files changed, 24 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 9d02598..b04a67d 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,16 @@ Give a try, use the included `testcases.php` to generate a report: *Example: -x="php,inc"* ``` +**-e** +``` + Exclusion tags that you can add above a line that is being flagged. Most useful for nuances which will remain in subsequent reports. + *Example: -e="@ignoreNextLine"* + Code: + // @ignoreNextLine + foreach ($array as &$byRef) { + +``` + **--php** ``` File path to the PHP binary to use for syntax checking. diff --git a/classes/options.php b/classes/options.php index 6ad718f..6eba1e4 100644 --- a/classes/options.php +++ b/classes/options.php @@ -55,9 +55,9 @@ class options { 'f' => [ 'option' => self::OPTION_REQUIRED, 'value' => self::VALUE_REQUIRED, - 'comment' => 'Path to the file or folder to run against.', + 'comment' => 'Path to the files or folders to run against.', 'description' => 'The location of the file or folder to use for generating the report. A fully qualified path is recommended. Relative paths will be based off the php7mar folder.', - 'example' => '-f="/path/to/folder"' + 'example' => '-f="/path/to/folder,path/to/file"', ], 'r' => [ 'option' => self::OPTION_OPTIONAL, @@ -78,6 +78,13 @@ class options { 'syntax' ] ], + 'e' => [ + 'option' => self::OPTION_OPTIONAL, + 'value' => self::VALUE_REQUIRED, + 'comment' => 'Exclusion tag to ignore next line nuance.', + 'description' => 'Add // @excludeNextLine on the line above a nuance, for instance, and it will not come up in subsequent results.', + 'example' => '-t="@excludeNextLine"' + ], 'x' => [ 'option' => self::OPTION_OPTIONAL, 'value' => self::VALUE_REQUIRED, diff --git a/composer.json b/composer.json index 325c775..efdf45f 100644 --- a/composer.json +++ b/composer.json @@ -19,5 +19,8 @@ ], "require": { "php": ">=5.4.0" - } + }, + "bin": [ + "mar.php" + ] } diff --git a/mar.php b/mar.php index 0762c4d..46d4de0 100644 --- a/mar.php +++ b/mar.php @@ -142,8 +142,7 @@ private function run() { // on the line before. -x="@fakeBug" and then on the line before nuance, you can // include the following and it won't come up in subsequent reports: // @fakeBug - $exclusionTag = $this->options->getOption('x'); - $exclusionTag = is_array($exclusionTag) ? array_shift($exclusionTag) : false; + $exclusionTag = $this->options->getOption('e'); if ($exclusionTag && isset($lines[$index-1]) && strpos($lines[$index-1], $exclusionTag)) { continue; }