Skip to content

Commit 3a947ef

Browse files
committed
small refactoring
1 parent 329088d commit 3a947ef

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

src/RobotLoader/RobotLoader.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -253,20 +253,19 @@ private function refreshClasses(): void
253253
private function createFileIterator(string $dir): Nette\Utils\Finder
254254
{
255255
if (!is_dir($dir)) {
256-
throw new Nette\IOException(sprintf("File or directory '%s' not found.", $dir));
256+
throw new Nette\IOException(sprintf("Directory '%s' not found.", $dir));
257257
}
258258

259259
$dir = realpath($dir) ?: $dir; // realpath does not work in phar
260260
$disallow = [];
261261
foreach (array_merge($this->ignoreDirs, $this->excludeDirs) as $item) {
262262
if ($item = realpath($item)) {
263-
$disallow[FileSystem::unixSlashes($item)] = true;
263+
$disallow[$item] = true;
264264
}
265265
}
266266

267267
return Nette\Utils\Finder::findFiles($this->acceptFiles)
268-
->filter($filter = fn(SplFileInfo $file) => $file->getRealPath() === false
269-
|| !isset($disallow[FileSystem::unixSlashes($file->getRealPath())]))
268+
->filter($filter = fn(SplFileInfo $file) => $file->getRealPath() === false || !isset($disallow[$file->getRealPath()]))
270269
->descentFilter($filter)
271270
->from($dir)
272271
->exclude($this->ignoreDirs);
@@ -286,7 +285,7 @@ private function updateFile(string $file): void
286285
foreach ($foundClasses as $class) {
287286
[$prevFile, $prevMtime] = $this->classes[$class] ?? null;
288287

289-
if (isset($prevFile) && @filemtime($prevFile) !== $prevMtime) { // @ file may not exists
288+
if (isset($prevFile) && @filemtime($prevFile) !== $prevMtime) { // @ file may not exist
290289
$this->updateFile($prevFile);
291290
[$prevFile] = $this->classes[$class] ?? null;
292291
}

tests/Loaders/RobotLoader.phar.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ $loader->addDirectory("phar://$pharFile/non-dir");
4848
Assert::exception(
4949
fn() => $loader->rebuild(),
5050
Nette\IOException::class,
51-
"File or directory 'phar://$pharFile/non-dir' not found.",
51+
"Directory 'phar://$pharFile/non-dir' not found.",
5252
);
5353

5454

@@ -58,5 +58,5 @@ $loader->addDirectory("phar://$pharFile/non-file.php");
5858
Assert::exception(
5959
fn() => $loader->rebuild(),
6060
Nette\IOException::class,
61-
"File or directory 'phar://$pharFile/non-file.php' not found.",
61+
"Directory 'phar://$pharFile/non-file.php' not found.",
6262
);

0 commit comments

Comments
 (0)