From 4d78fcbad4f6f7016f9cdb0863405697d62beaed Mon Sep 17 00:00:00 2001 From: Chris Kankiewicz Date: Mon, 17 Mar 2025 13:04:13 -0700 Subject: [PATCH] Minor optimizations --- app/config/container.php | 4 ++-- app/src/Controllers/ZipController.php | 2 +- app/src/Factories/TranslationFactory.php | 2 +- app/src/ViewFunctions/Vite.php | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/config/container.php b/app/config/container.php index 81d8db3..8cb8a91 100644 --- a/app/config/container.php +++ b/app/config/container.php @@ -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, diff --git a/app/src/Controllers/ZipController.php b/app/src/Controllers/ZipController.php index 08abce0..59194aa 100644 --- a/app/src/Controllers/ZipController.php +++ b/app/src/Controllers/ZipController.php @@ -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(); }) ); diff --git a/app/src/Factories/TranslationFactory.php b/app/src/Factories/TranslationFactory.php index f7b6b77..ad42878 100644 --- a/app/src/Factories/TranslationFactory.php +++ b/app/src/Factories/TranslationFactory.php @@ -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') diff --git a/app/src/ViewFunctions/Vite.php b/app/src/ViewFunctions/Vite.php index f8773ed..c2b1a40 100644 --- a/app/src/ViewFunctions/Vite.php +++ b/app/src/ViewFunctions/Vite.php @@ -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('', $manifest->{$asset}->file), '.css' => sprintf('', $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('', $_SERVER['HTTP_HOST'], $asset), '.css' => sprintf('', $_SERVER['HTTP_HOST'], $asset), default => throw new UnexpectedValueException(sprintf('Unsupported asset type: %s', $asset))