mirror of
https://github.com/DirectoryLister/DirectoryLister.git
synced 2025-08-18 03:41:25 +02:00
Minor optimizations
This commit is contained in:
@@ -28,13 +28,13 @@ return [
|
||||
'views_path' => string('{app_path}/views'),
|
||||
|
||||
/** Path helpers */
|
||||
'full_path' => value(fn (string $path, Config $config): string => $config->get('files_path') . '/' . $path),
|
||||
'full_path' => value(static fn (string $path, Config $config): string => $config->get('files_path') . '/' . $path),
|
||||
|
||||
/** Array of application files (to be hidden) */
|
||||
'app_files' => ['app', 'index.php', '.analytics', '.env', '.env.example', '.hidden'],
|
||||
|
||||
/** Array of application middlewares */
|
||||
'middlewares' => fn (): array => [
|
||||
'middlewares' => [
|
||||
Middlewares\WhoopsMiddleware::class,
|
||||
Middlewares\PruneCacheMiddleware::class,
|
||||
Middlewares\CacheControlMiddleware::class,
|
||||
|
@@ -58,7 +58,7 @@ class ZipController
|
||||
$size = $zip->finish();
|
||||
|
||||
$response = $this->augmentHeadersWithEstimatedSize($response, $size)->withBody(
|
||||
new CallbackStream(function () use ($zip) {
|
||||
new CallbackStream(static function () use ($zip) {
|
||||
$zip->executeSimulation();
|
||||
})
|
||||
);
|
||||
|
@@ -47,7 +47,7 @@ class TranslationFactory
|
||||
protected function translations(): array
|
||||
{
|
||||
return $this->cache->get('translations', function (): array {
|
||||
return array_values(array_map(function (SplFileInfo $file): string {
|
||||
return array_values(array_map(static function (SplFileInfo $file): string {
|
||||
return $file->getBasename('.yaml');
|
||||
}, iterator_to_array(
|
||||
Finder::create()->in($this->config->get('translations_path'))->name('*.yaml')
|
||||
|
@@ -34,7 +34,7 @@ class Vite extends ViewFunction
|
||||
$manifest = json_decode((string) file_get_contents($this->config->get('manifest_path')), flags: JSON_THROW_ON_ERROR);
|
||||
|
||||
return Collection::make($assets)->map(
|
||||
fn (string $asset): string => match (mb_substr($asset, (int) mb_strrpos($asset, '.'))) {
|
||||
static fn (string $asset): string => match (mb_substr($asset, (int) mb_strrpos($asset, '.'))) {
|
||||
'.js' => sprintf('<script type="module" src="app/%s"></script>', $manifest->{$asset}->file),
|
||||
'.css' => sprintf('<link rel="stylesheet" href="app/%s">', $manifest->{$asset}->file),
|
||||
default => throw new UnexpectedValueException(sprintf('Unsupported asset type: %s', $asset))
|
||||
@@ -50,7 +50,7 @@ class Vite extends ViewFunction
|
||||
private function getDevTags(array $assets): Collection
|
||||
{
|
||||
return Collection::make($assets)->map(
|
||||
fn (string $asset): string => match (mb_substr($asset, (int) mb_strrpos($asset, '.'))) {
|
||||
static fn (string $asset): string => match (mb_substr($asset, (int) mb_strrpos($asset, '.'))) {
|
||||
'.js' => sprintf('<script type="module" src="http://%s:5173/%s"></script>', $_SERVER['HTTP_HOST'], $asset),
|
||||
'.css' => sprintf('<link rel="stylesheet" href="http://%s:5173/%s">', $_SERVER['HTTP_HOST'], $asset),
|
||||
default => throw new UnexpectedValueException(sprintf('Unsupported asset type: %s', $asset))
|
||||
|
Reference in New Issue
Block a user