Skip to content

Commit

Permalink
File::process(): don't apply include/exclude patterns to STDIN
Browse files Browse the repository at this point in the history
Note: using `trim()` to remove potential quotes around `STDIN` which are sometimes passed by IDEs.
  • Loading branch information
jrfnl authored and gsherwood committed Oct 26, 2020
1 parent 9d58372 commit 7171973
Showing 1 changed file with 32 additions and 30 deletions.
62 changes: 32 additions & 30 deletions src/Files/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -442,30 +442,11 @@ public function process()
continue;
}

// If the file path matches one of our ignore patterns, skip it.
// While there is support for a type of each pattern
// (absolute or relative) we don't actually support it here.
foreach ($listenerData['ignore'] as $pattern) {
// We assume a / directory separator, as do the exclude rules
// most developers write, so we need a special case for any system
// that is different.
if (DIRECTORY_SEPARATOR === '\\') {
$pattern = str_replace('/', '\\\\', $pattern);
}

$pattern = '`'.$pattern.'`i';
if (preg_match($pattern, $this->path) === 1) {
$this->ignoredListeners[$class] = true;
continue(2);
}
}

// If the file path does not match one of our include patterns, skip it.
// While there is support for a type of each pattern
// (absolute or relative) we don't actually support it here.
if (empty($listenerData['include']) === false) {
$included = false;
foreach ($listenerData['include'] as $pattern) {
if (trim($this->path, '\'"') !== 'STDIN') {
// If the file path matches one of our ignore patterns, skip it.
// While there is support for a type of each pattern
// (absolute or relative) we don't actually support it here.
foreach ($listenerData['ignore'] as $pattern) {
// We assume a / directory separator, as do the exclude rules
// most developers write, so we need a special case for any system
// that is different.
Expand All @@ -475,15 +456,36 @@ public function process()

$pattern = '`'.$pattern.'`i';
if (preg_match($pattern, $this->path) === 1) {
$included = true;
break;
$this->ignoredListeners[$class] = true;
continue(2);
}
}

if ($included === false) {
$this->ignoredListeners[$class] = true;
continue;
}
// If the file path does not match one of our include patterns, skip it.
// While there is support for a type of each pattern
// (absolute or relative) we don't actually support it here.
if (empty($listenerData['include']) === false) {
$included = false;
foreach ($listenerData['include'] as $pattern) {
// We assume a / directory separator, as do the exclude rules
// most developers write, so we need a special case for any system
// that is different.
if (DIRECTORY_SEPARATOR === '\\') {
$pattern = str_replace('/', '\\\\', $pattern);
}

$pattern = '`'.$pattern.'`i';
if (preg_match($pattern, $this->path) === 1) {
$included = true;
break;
}
}

if ($included === false) {
$this->ignoredListeners[$class] = true;
continue;
}
}//end if
}//end if

$this->activeListener = $class;
Expand Down

0 comments on commit 7171973

Please sign in to comment.