Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Jan 18, 2023
1 parent 2e60d84 commit 2970fc5
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions src/RobotLoader/RobotLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace Nette\Loaders;

use Nette;
use Nette\Utils\FileSystem;
use SplFileInfo;


Expand Down Expand Up @@ -248,7 +249,7 @@ private function refreshClasses(): void


/**
* Creates an iterator scaning directory for PHP files and subdirectories.
* Creates an iterator scanning directory for PHP files and subdirectories.
* @throws Nette\IOException if path is not found
*/
private function createFileIterator(string $dir): Nette\Utils\Finder
Expand All @@ -258,21 +259,16 @@ private function createFileIterator(string $dir): Nette\Utils\Finder
}

$dir = realpath($dir) ?: $dir; // realpath does not work in phar


$disallow = [];
foreach (array_merge($this->ignoreDirs, $this->excludeDirs) as $item) {
if ($item = realpath($item)) {
$disallow[str_replace('\\', '/', $item)] = true;
$disallow[FileSystem::unixSlashes($item)] = true;
}
}

return Nette\Utils\Finder::findFiles($this->acceptFiles)
->filter($filter = function (SplFileInfo $file) use ($disallow) {
return $file->getRealPath() === false
? true
: !isset($disallow[str_replace('\\', '/', $file->getRealPath())]);
})
->filter($filter = fn(SplFileInfo $file) => $file->getRealPath() === false
|| !isset($disallow[FileSystem::unixSlashes($file->getRealPath())]))
->descentFilter($filter)
->from($dir)
->exclude($this->ignoreDirs);
Expand Down Expand Up @@ -408,7 +404,7 @@ public function setAutoRefresh(bool $on = true): static
*/
public function setTempDirectory(string $dir): static
{
Nette\Utils\FileSystem::createDir($dir);
FileSystem::createDir($dir);
$this->tempDirectory = $dir;
return $this;
}
Expand Down

0 comments on commit 2970fc5

Please sign in to comment.