Skip to content

Commit 8a4db03

Browse files
committed
ViolationParser/FilesystemSniffFinder: minor regex simplifications
Similar to 6
1 parent 806997b commit 8a4db03

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/Parser/ViolationParser.php

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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)