Skip to content

Commit b25ee48

Browse files
authored
Merge pull request #8 from PHPCSStandards/feature/minor-regex-tweak
ViolationParser/FilesystemSniffFinder: minor regex simplifications
2 parents 61e8c27 + 8a4db03 commit b25ee48

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/Parser/ViolationParser.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ public function parse(string $xmlFilePath): Violation
2727

2828
private function getErrorCode(string $xmlFilePath): string
2929
{
30-
$part = '([^\/]*)';
31-
preg_match("/$part\/Docs\/$part\/{$part}Standard\/$part\.xml/", $xmlFilePath, $matches);
30+
$part = '([^/]*)';
31+
preg_match("`$part/Docs/$part/{$part}Standard/$part\.xml$`", $xmlFilePath, $matches);
3232
if ($matches === []) {
3333
throw NotAViolationPath::fromPath($xmlFilePath);
3434
}

src/SniffFinder/FilesystemSniffFinder.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ private function recursiveSearch(Folder $folder): Iterator
4343
$dirs = new RecursiveDirectoryIterator($folder->getPath());
4444
$files = new RecursiveIteratorIterator($dirs);
4545
return new CallbackFilterIterator($files, function (SplFileInfo $fileInfo) {
46-
return preg_match('/\.php$/', $fileInfo->getPathname()) && !preg_match('/\/Tests\//', $fileInfo->getPathname());
46+
return preg_match('/\.php$/', $fileInfo->getPathname()) && !preg_match('`/Tests/`', $fileInfo->getPathname());
4747
});
4848
}
4949

0 commit comments

Comments
 (0)