From 8a4db0354150428043377deb6251295f63dfa2dd Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 18 Mar 2021 06:42:48 +0100 Subject: [PATCH] ViolationParser/FilesystemSniffFinder: minor regex simplifications Similar to 6 --- src/Parser/ViolationParser.php | 4 ++-- src/SniffFinder/FilesystemSniffFinder.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Parser/ViolationParser.php b/src/Parser/ViolationParser.php index cabab9c..e9d27f5 100644 --- a/src/Parser/ViolationParser.php +++ b/src/Parser/ViolationParser.php @@ -27,8 +27,8 @@ public function parse(string $xmlFilePath): Violation private function getErrorCode(string $xmlFilePath): string { - $part = '([^\/]*)'; - preg_match("/$part\/Docs\/$part\/{$part}Standard\/$part\.xml/", $xmlFilePath, $matches); + $part = '([^/]*)'; + preg_match("`$part/Docs/$part/{$part}Standard/$part\.xml$`", $xmlFilePath, $matches); if ($matches === []) { throw NotAViolationPath::fromPath($xmlFilePath); } diff --git a/src/SniffFinder/FilesystemSniffFinder.php b/src/SniffFinder/FilesystemSniffFinder.php index 58f744f..d310f5f 100644 --- a/src/SniffFinder/FilesystemSniffFinder.php +++ b/src/SniffFinder/FilesystemSniffFinder.php @@ -43,7 +43,7 @@ private function recursiveSearch(Folder $folder): Iterator $dirs = new RecursiveDirectoryIterator($folder->getPath()); $files = new RecursiveIteratorIterator($dirs); return new CallbackFilterIterator($files, function (SplFileInfo $fileInfo) { - return preg_match('/\.php$/', $fileInfo->getPathname()) && !preg_match('/\/Tests\//', $fileInfo->getPathname()); + return preg_match('/\.php$/', $fileInfo->getPathname()) && !preg_match('`/Tests/`', $fileInfo->getPathname()); }); }