Skip to content
Merged
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
154 changes: 80 additions & 74 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 Expand Up @@ -965,59 +967,63 @@ protected function addMessage($error, $message, $line, $column, $code, $data, $s

// Make sure we are not ignoring this file.
$included = null;
foreach ($checkCodes as $checkCode) {
$patterns = null;

if (isset($this->configCache['includePatterns'][$checkCode]) === true) {
$patterns = $this->configCache['includePatterns'][$checkCode];
$excluding = false;
} else if (isset($this->configCache['ignorePatterns'][$checkCode]) === true) {
$patterns = $this->configCache['ignorePatterns'][$checkCode];
$excluding = true;
}

if ($patterns === null) {
continue;
}
if (trim($this->path, '\'"') === 'STDIN') {
$included = true;
} else {
foreach ($checkCodes as $checkCode) {
$patterns = null;

if (isset($this->configCache['includePatterns'][$checkCode]) === true) {
$patterns = $this->configCache['includePatterns'][$checkCode];
$excluding = false;
} else if (isset($this->configCache['ignorePatterns'][$checkCode]) === true) {
$patterns = $this->configCache['ignorePatterns'][$checkCode];
$excluding = true;
}

foreach ($patterns as $pattern => $type) {
// While there is support for a type of each pattern
// (absolute or relative) we don't actually support it here.
$replacements = [
'\\,' => ',',
'*' => '.*',
];

// 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 === '\\') {
$replacements['/'] = '\\\\';
if ($patterns === null) {
continue;
}

$pattern = '`'.strtr($pattern, $replacements).'`i';
$matched = preg_match($pattern, $this->path);
foreach ($patterns as $pattern => $type) {
// While there is support for a type of each pattern
// (absolute or relative) we don't actually support it here.
$replacements = [
'\\,' => ',',
'*' => '.*',
];

if ($matched === 0) {
if ($excluding === false && $included === null) {
// This file path is not being included.
$included = false;
// 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 === '\\') {
$replacements['/'] = '\\\\';
}

continue;
}
$pattern = '`'.strtr($pattern, $replacements).'`i';
$matched = preg_match($pattern, $this->path);

if ($excluding === true) {
// This file path is being excluded.
$this->ignoredCodes[$checkCode] = true;
return false;
}
if ($matched === 0) {
if ($excluding === false && $included === null) {
// This file path is not being included.
$included = false;
}

// This file path is being included.
$included = true;
break;
continue;
}

if ($excluding === true) {
// This file path is being excluded.
$this->ignoredCodes[$checkCode] = true;
return false;
}

// This file path is being included.
$included = true;
break;
}//end foreach
}//end foreach
}//end foreach
}//end if

if ($included === false) {
// There were include rules set, but this file
Expand Down