mirror of
https://github.com/DirectoryLister/DirectoryLister.git
synced 2025-08-25 15:01:16 +02:00
Made several closures static
This commit is contained in:
@@ -85,7 +85,7 @@ return [
|
||||
* Default value: Array loaded from '.hidden' file if present, otherwise
|
||||
* an empty array ([])
|
||||
*/
|
||||
'hidden_files' => function (ContainerInterface $container): array {
|
||||
'hidden_files' => static function (ContainerInterface $container): array {
|
||||
if (! is_readable($container->get('hidden_files_list'))) {
|
||||
return [];
|
||||
}
|
||||
@@ -158,7 +158,7 @@ return [
|
||||
*
|
||||
* Default value: Array loaded from 'icons.php' config file
|
||||
*/
|
||||
'icons' => function (ContainerInterface $container): array {
|
||||
'icons' => static function (ContainerInterface $container): array {
|
||||
return require $container->get('icons_config');
|
||||
},
|
||||
];
|
||||
|
@@ -89,9 +89,9 @@ class DirectoryController
|
||||
|
||||
$readmes = (clone $files)->name('/^README(?:\..+)?$/i');
|
||||
|
||||
$readmes->filter(function (SplFileInfo $file) {
|
||||
$readmes->filter(static function (SplFileInfo $file) {
|
||||
return (bool) preg_match('/text\/.+/', mime_content_type($file->getPathname()));
|
||||
})->sort(function (SplFileInfo $file1, SplFileInfo $file2) {
|
||||
})->sort(static function (SplFileInfo $file1, SplFileInfo $file2) {
|
||||
return $file1->getExtension() <=> $file2->getExtension();
|
||||
});
|
||||
|
||||
|
@@ -91,7 +91,7 @@ class FinderFactory
|
||||
$this->container->get('base_path') . '/' . $file,
|
||||
GLOB_BRACE | GLOB_NOSORT
|
||||
);
|
||||
})->flatten()->map(function (string $file): string {
|
||||
})->flatten()->map(static function (string $file): string {
|
||||
return realpath($file);
|
||||
})->unique();
|
||||
}
|
||||
|
@@ -41,13 +41,13 @@ class Breadcrumbs extends ViewFunction
|
||||
{
|
||||
return Str::explode($path, $this->directorySeparator)->diff(
|
||||
explode($this->directorySeparator, $this->container->get('base_path'))
|
||||
)->filter(function (string $crumb): bool {
|
||||
)->filter(static function (string $crumb): bool {
|
||||
return ! in_array($crumb, [null, '.']);
|
||||
})->reduce(function (Collection $carry, string $crumb): Collection {
|
||||
return $carry->put($crumb, ltrim(
|
||||
$carry->last() . $this->directorySeparator . rawurlencode($crumb), $this->directorySeparator
|
||||
));
|
||||
}, new Collection)->map(function (string $path, string $name): string {
|
||||
}, new Collection)->map(static function (string $path, string $name): string {
|
||||
return sprintf('?dir=%s', $path);
|
||||
});
|
||||
}
|
||||
|
@@ -32,10 +32,10 @@ class ParentUrl extends ViewFunction
|
||||
public function __invoke(string $path)
|
||||
{
|
||||
$parentDir = Str::explode($path, $this->directorySeparator)->map(
|
||||
function (string $segment): string {
|
||||
static function (string $segment): string {
|
||||
return rawurlencode($segment);
|
||||
}
|
||||
)->filter(function (?string $value): bool {
|
||||
)->filter(static function (?string $value): bool {
|
||||
return $value !== null;
|
||||
})->slice(0, -1)->implode($this->directorySeparator);
|
||||
|
||||
|
@@ -56,7 +56,7 @@ class Url extends ViewFunction
|
||||
protected function escape(string $path): string
|
||||
{
|
||||
return Str::explode($path, $this->directorySeparator)->map(
|
||||
function (string $segment): string {
|
||||
static function (string $segment): string {
|
||||
return rawurlencode($segment);
|
||||
}
|
||||
)->implode($this->directorySeparator);
|
||||
|
@@ -16,7 +16,7 @@ class MiddlewareManagerTest extends TestCase
|
||||
|
||||
public function test_it_registers_application_middlewares(): void
|
||||
{
|
||||
$arguments = array_map(function (string $middleware): array {
|
||||
$arguments = array_map(static function (string $middleware): array {
|
||||
return [$middleware];
|
||||
}, self::MIDDLEWARES);
|
||||
|
||||
|
@@ -30,7 +30,7 @@ class FinderFactoryTest extends TestCase
|
||||
public function test_it_can_sort_by_a_user_provided_closure(): void
|
||||
{
|
||||
$this->container->set('sort_order', \DI\value(
|
||||
function (SplFileInfo $file1, SplFileInfo $file2) {
|
||||
static function (SplFileInfo $file1, SplFileInfo $file2) {
|
||||
return $file1->getSize() <=> $file2->getSize();
|
||||
}
|
||||
));
|
||||
@@ -92,7 +92,7 @@ class FinderFactoryTest extends TestCase
|
||||
|
||||
protected function getFilesArray(Finder $finder): array
|
||||
{
|
||||
$files = array_map(function (SplFileInfo $file) {
|
||||
$files = array_map(static function (SplFileInfo $file) {
|
||||
return $file->getFilename();
|
||||
}, iterator_to_array($finder));
|
||||
|
||||
|
Reference in New Issue
Block a user