Skip to content
This repository has been archived by the owner on Feb 27, 2020. It is now read-only.

Add an option to print to stderr as files are being scanned #32

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ Give a try, use the included `testcases.php` to generate a report:
*Example: -x="php,inc"*
```

**-p**
```
Print progress output.
Print a message to stderr as each file is being analyzed.
*Example: -p*
```

**--php**
```
File path to the PHP binary to use for syntax checking.
Expand Down
9 changes: 8 additions & 1 deletion classes/options.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,14 @@ class options {
'description' => 'A comma separated list of file extensions to consider as PHP files. Defaults to "php"',
'example' => '-x="php,inc"',
'comma_delimited' => true
]
],
'p' => [
'option' => self::OPTION_OPTIONAL,
'value' => self::VALUE_NONE,
'comment' => 'Print progress output.',
'description' => 'Print a message to stderr as each file is being analyzed.',
'example' => '-p',
],
];

/**
Expand Down
4 changes: 4 additions & 0 deletions mar.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,12 @@ private function run() {
} else {
$checkSyntax = false;
}
$print_progress = $this->options->getOption('p');

while (($lines = $this->scanner->scanNextFile()) !== false) {
if ($print_progress) {
fprintf(STDERR, "Scanning '%s'\n", $filePath);
}
$totalFiles++;

//Check syntax and assign a line to grab if needed.
Expand Down