Skip to content

Commit f117e81

Browse files
committed
Merge branch 'feature/caching-file-hash-minor-efficiency-tweak' of https://github.com/jrfnl/PHP_CodeSniffer
2 parents 178d957 + 15ddd84 commit f117e81

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/Util/Cache.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,22 +95,25 @@ public static function load(Ruleset $ruleset, Config $config)
9595
// hash. This ensures that core PHPCS changes will also invalidate the cache.
9696
// Note that we ignore sniffs here, and any files that don't affect
9797
// the outcome of the run.
98-
$di = new \RecursiveDirectoryIterator($installDir);
98+
$di = new \RecursiveDirectoryIterator(
99+
$installDir,
100+
(\FilesystemIterator::KEY_AS_PATHNAME | \FilesystemIterator::CURRENT_AS_FILEINFO | \FilesystemIterator::SKIP_DOTS)
101+
);
99102
$filter = new \RecursiveCallbackFilterIterator(
100103
$di,
101104
function ($file, $key, $iterator) {
102-
// Skip hidden files.
105+
// Skip non-php files.
103106
$filename = $file->getFilename();
104-
if (substr($filename, 0, 1) === '.') {
107+
if ($file->isFile() === true && substr($filename, -4) !== '.php') {
105108
return false;
106109
}
107110

108-
$filePath = Common::realpath($file->getPathname());
111+
$filePath = Common::realpath($key);
109112
if ($filePath === false) {
110113
return false;
111114
}
112115

113-
if (is_dir($filePath) === true
116+
if ($iterator->hasChildren() === true
114117
&& ($filename === 'Standards'
115118
|| $filename === 'Exceptions'
116119
|| $filename === 'Reports'

0 commit comments

Comments
 (0)