Skip to content

Commit 0d79723

Browse files
committed
File::process(): don't apply include/exclude patterns to STDIN
Note: using `trim()` to remove potential quotes around `STDIN` which are sometimes passed by IDEs.
1 parent db9089d commit 0d79723

File tree

1 file changed

+32
-30
lines changed

1 file changed

+32
-30
lines changed

src/Files/File.php

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -442,30 +442,11 @@ public function process()
442442
continue;
443443
}
444444

445-
// If the file path matches one of our ignore patterns, skip it.
446-
// While there is support for a type of each pattern
447-
// (absolute or relative) we don't actually support it here.
448-
foreach ($listenerData['ignore'] as $pattern) {
449-
// We assume a / directory separator, as do the exclude rules
450-
// most developers write, so we need a special case for any system
451-
// that is different.
452-
if (DIRECTORY_SEPARATOR === '\\') {
453-
$pattern = str_replace('/', '\\\\', $pattern);
454-
}
455-
456-
$pattern = '`'.$pattern.'`i';
457-
if (preg_match($pattern, $this->path) === 1) {
458-
$this->ignoredListeners[$class] = true;
459-
continue(2);
460-
}
461-
}
462-
463-
// If the file path does not match one of our include patterns, skip it.
464-
// While there is support for a type of each pattern
465-
// (absolute or relative) we don't actually support it here.
466-
if (empty($listenerData['include']) === false) {
467-
$included = false;
468-
foreach ($listenerData['include'] as $pattern) {
445+
if (trim($this->path, '\'"') !== 'STDIN') {
446+
// If the file path matches one of our ignore patterns, skip it.
447+
// While there is support for a type of each pattern
448+
// (absolute or relative) we don't actually support it here.
449+
foreach ($listenerData['ignore'] as $pattern) {
469450
// We assume a / directory separator, as do the exclude rules
470451
// most developers write, so we need a special case for any system
471452
// that is different.
@@ -475,15 +456,36 @@ public function process()
475456

476457
$pattern = '`'.$pattern.'`i';
477458
if (preg_match($pattern, $this->path) === 1) {
478-
$included = true;
479-
break;
459+
$this->ignoredListeners[$class] = true;
460+
continue(2);
480461
}
481462
}
482463

483-
if ($included === false) {
484-
$this->ignoredListeners[$class] = true;
485-
continue;
486-
}
464+
// If the file path does not match one of our include patterns, skip it.
465+
// While there is support for a type of each pattern
466+
// (absolute or relative) we don't actually support it here.
467+
if (empty($listenerData['include']) === false) {
468+
$included = false;
469+
foreach ($listenerData['include'] as $pattern) {
470+
// We assume a / directory separator, as do the exclude rules
471+
// most developers write, so we need a special case for any system
472+
// that is different.
473+
if (DIRECTORY_SEPARATOR === '\\') {
474+
$pattern = str_replace('/', '\\\\', $pattern);
475+
}
476+
477+
$pattern = '`'.$pattern.'`i';
478+
if (preg_match($pattern, $this->path) === 1) {
479+
$included = true;
480+
break;
481+
}
482+
}
483+
484+
if ($included === false) {
485+
$this->ignoredListeners[$class] = true;
486+
continue;
487+
}
488+
}//end if
487489
}//end if
488490

489491
$this->activeListener = $class;

0 commit comments

Comments
 (0)