Skip to content

Commit 9dd6d64

Browse files
committed
Revert "File::addMessage(): don't apply include/exclude patterns to STDIN"
This reverts commit a95569c.
1 parent a978246 commit 9dd6d64

File tree

1 file changed

+44
-48
lines changed

1 file changed

+44
-48
lines changed

src/Files/File.php

Lines changed: 44 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -965,63 +965,59 @@ protected function addMessage($error, $message, $line, $column, $code, $data, $s
965965

966966
// Make sure we are not ignoring this file.
967967
$included = null;
968-
if (trim($this->path, '\'"') === 'STDIN') {
969-
$included = true;
970-
} else {
971-
foreach ($checkCodes as $checkCode) {
972-
$patterns = null;
973-
974-
if (isset($this->configCache['includePatterns'][$checkCode]) === true) {
975-
$patterns = $this->configCache['includePatterns'][$checkCode];
976-
$excluding = false;
977-
} else if (isset($this->configCache['ignorePatterns'][$checkCode]) === true) {
978-
$patterns = $this->configCache['ignorePatterns'][$checkCode];
979-
$excluding = true;
980-
}
968+
foreach ($checkCodes as $checkCode) {
969+
$patterns = null;
970+
971+
if (isset($this->configCache['includePatterns'][$checkCode]) === true) {
972+
$patterns = $this->configCache['includePatterns'][$checkCode];
973+
$excluding = false;
974+
} else if (isset($this->configCache['ignorePatterns'][$checkCode]) === true) {
975+
$patterns = $this->configCache['ignorePatterns'][$checkCode];
976+
$excluding = true;
977+
}
981978

982-
if ($patterns === null) {
983-
continue;
979+
if ($patterns === null) {
980+
continue;
981+
}
982+
983+
foreach ($patterns as $pattern => $type) {
984+
// While there is support for a type of each pattern
985+
// (absolute or relative) we don't actually support it here.
986+
$replacements = [
987+
'\\,' => ',',
988+
'*' => '.*',
989+
];
990+
991+
// We assume a / directory separator, as do the exclude rules
992+
// most developers write, so we need a special case for any system
993+
// that is different.
994+
if (DIRECTORY_SEPARATOR === '\\') {
995+
$replacements['/'] = '\\\\';
984996
}
985997

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

994-
// We assume a / directory separator, as do the exclude rules
995-
// most developers write, so we need a special case for any system
996-
// that is different.
997-
if (DIRECTORY_SEPARATOR === '\\') {
998-
$replacements['/'] = '\\\\';
1001+
if ($matched === 0) {
1002+
if ($excluding === false && $included === null) {
1003+
// This file path is not being included.
1004+
$included = false;
9991005
}
10001006

1001-
$pattern = '`'.strtr($pattern, $replacements).'`i';
1002-
$matched = preg_match($pattern, $this->path);
1003-
1004-
if ($matched === 0) {
1005-
if ($excluding === false && $included === null) {
1006-
// This file path is not being included.
1007-
$included = false;
1008-
}
1009-
1010-
continue;
1011-
}
1007+
continue;
1008+
}
10121009

1013-
if ($excluding === true) {
1014-
// This file path is being excluded.
1015-
$this->ignoredCodes[$checkCode] = true;
1016-
return false;
1017-
}
1010+
if ($excluding === true) {
1011+
// This file path is being excluded.
1012+
$this->ignoredCodes[$checkCode] = true;
1013+
return false;
1014+
}
10181015

1019-
// This file path is being included.
1020-
$included = true;
1021-
break;
1022-
}//end foreach
1016+
// This file path is being included.
1017+
$included = true;
1018+
break;
10231019
}//end foreach
1024-
}//end if
1020+
}//end foreach
10251021

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

0 commit comments

Comments
 (0)