From b0877a3bf7132d8dbc17e909940cbb1addf12b2d Mon Sep 17 00:00:00 2001 From: Chris Kankiewicz Date: Tue, 18 Mar 2025 11:28:01 -0700 Subject: [PATCH] Modified visibility of several functions and properties --- app/src/Bootstrap/BootManager.php | 2 +- app/src/Controllers/DirectoryController.php | 2 +- app/src/Controllers/FileInfoController.php | 2 +- app/src/Controllers/ZipController.php | 6 +++--- app/src/Factories/FinderFactory.php | 2 +- app/src/Factories/TranslationFactory.php | 2 +- tests/Bootstrap/MiddlewareManagerTest.php | 2 +- tests/Controllers/IndexControllerTest.php | 11 +++++------ tests/Factories/FinderFactoryTest.php | 2 +- tests/Middlewares/RegisterGlobalsMiddlewareTest.php | 6 +++--- tests/ViewFunctions/TranslateTest.php | 2 +- 11 files changed, 19 insertions(+), 20 deletions(-) diff --git a/app/src/Bootstrap/BootManager.php b/app/src/Bootstrap/BootManager.php index 6af714c..a7cd9c5 100644 --- a/app/src/Bootstrap/BootManager.php +++ b/app/src/Bootstrap/BootManager.php @@ -25,7 +25,7 @@ class BootManager } /** Determine if container compilation should be enabled. */ - protected static function containerCompilationEnabled(): bool + private static function containerCompilationEnabled(): bool { if (filter_var(getenv('APP_DEBUG'), FILTER_VALIDATE_BOOL)) { return false; diff --git a/app/src/Controllers/DirectoryController.php b/app/src/Controllers/DirectoryController.php index e980cef..8c1ba2a 100644 --- a/app/src/Controllers/DirectoryController.php +++ b/app/src/Controllers/DirectoryController.php @@ -47,7 +47,7 @@ class DirectoryController } /** Return the README file within a finder object. */ - protected function readme(Finder $files): ?SplFileInfo + private function readme(Finder $files): ?SplFileInfo { if (! $this->config->get('display_readmes')) { return null; diff --git a/app/src/Controllers/FileInfoController.php b/app/src/Controllers/FileInfoController.php index 55dfe0c..d0442c1 100644 --- a/app/src/Controllers/FileInfoController.php +++ b/app/src/Controllers/FileInfoController.php @@ -49,7 +49,7 @@ class FileInfoController * * @return array{md5: string, sha1: string, sha256: string} */ - protected function calculateHashes(SplFileInfo $file): array + private function calculateHashes(SplFileInfo $file): array { return [ 'md5' => (string) hash_file('md5', (string) $file->getRealPath()), diff --git a/app/src/Controllers/ZipController.php b/app/src/Controllers/ZipController.php index 4c12e65..60ca06c 100644 --- a/app/src/Controllers/ZipController.php +++ b/app/src/Controllers/ZipController.php @@ -68,7 +68,7 @@ class ZipController * * @throws \ZipStream\Exception */ - protected function createZip(string $path, Finder $files): ZipStream + private function createZip(string $path, Finder $files): ZipStream { $compressionMethod = $this->config->get('zip_compress') ? CompressionMethod::DEFLATE : CompressionMethod::STORE; @@ -98,7 +98,7 @@ class ZipController } /** Return the path to a file with the preceding root path stripped. */ - protected function stripPath(SplFileInfo $file, string $path): string + private function stripPath(SplFileInfo $file, string $path): string { $pattern = sprintf('/^%s%s?/', preg_quote($path, '/'), preg_quote(DIRECTORY_SEPARATOR, '/')); @@ -106,7 +106,7 @@ class ZipController } /** Generate the file name for a path. */ - protected function generateFileName(string $path): string + private function generateFileName(string $path): string { $filename = (string) Str::explode($path, DIRECTORY_SEPARATOR)->last(); diff --git a/app/src/Factories/FinderFactory.php b/app/src/Factories/FinderFactory.php index 4a9b8ff..1c0108e 100644 --- a/app/src/Factories/FinderFactory.php +++ b/app/src/Factories/FinderFactory.php @@ -55,7 +55,7 @@ class FinderFactory } /** Determine if a file should be hidden. */ - protected function isHidden(SplFileInfo $file): bool + private function isHidden(SplFileInfo $file): bool { if (! $this->pattern instanceof Pattern) { $this->pattern = Pattern::make(sprintf('%s{%s}', Pattern::escape( diff --git a/app/src/Factories/TranslationFactory.php b/app/src/Factories/TranslationFactory.php index 45abac8..481bd3e 100644 --- a/app/src/Factories/TranslationFactory.php +++ b/app/src/Factories/TranslationFactory.php @@ -46,7 +46,7 @@ class TranslationFactory * * @return list */ - protected function translations(): array + private function translations(): array { return $this->cache->get('translations', fn (): array => array_values(array_map( static fn (SplFileInfo $file): string => $file->getBasename('.yaml'), diff --git a/tests/Bootstrap/MiddlewareManagerTest.php b/tests/Bootstrap/MiddlewareManagerTest.php index e3fae84..50fce73 100644 --- a/tests/Bootstrap/MiddlewareManagerTest.php +++ b/tests/Bootstrap/MiddlewareManagerTest.php @@ -15,7 +15,7 @@ use Tests\TestCase; class MiddlewareManagerTest extends TestCase { /** @const Array of application middlewares */ - protected const MIDDLEWARES = [ + private const MIDDLEWARES = [ Middlewares\WhoopsMiddleware::class, Middlewares\PruneCacheMiddleware::class, Middlewares\CacheControlMiddleware::class, diff --git a/tests/Controllers/IndexControllerTest.php b/tests/Controllers/IndexControllerTest.php index 2db5324..5dc62d1 100644 --- a/tests/Controllers/IndexControllerTest.php +++ b/tests/Controllers/IndexControllerTest.php @@ -18,14 +18,13 @@ use Tests\TestCase; #[CoversClass(IndexController::class)] class IndexControllerTest extends TestCase { - /** @var Request&MockObject */ - protected $request; - - /** @var Response&MockObject */ - protected $response; - /** @var Container&MockObject */ protected $container; + /** @var Request&MockObject */ + private $request; + + /** @var Response&MockObject */ + private $response; public function setUp(): void { diff --git a/tests/Factories/FinderFactoryTest.php b/tests/Factories/FinderFactoryTest.php index 02293f4..cd3675c 100644 --- a/tests/Factories/FinderFactoryTest.php +++ b/tests/Factories/FinderFactoryTest.php @@ -156,7 +156,7 @@ class FinderFactoryTest extends TestCase ))(); } - protected function getFilesArray(Finder $finder): array + private function getFilesArray(Finder $finder): array { $files = array_map( static fn (SplFileInfo $file): string => $file->getFilename(), diff --git a/tests/Middlewares/RegisterGlobalsMiddlewareTest.php b/tests/Middlewares/RegisterGlobalsMiddlewareTest.php index c068d27..d0957b4 100644 --- a/tests/Middlewares/RegisterGlobalsMiddlewareTest.php +++ b/tests/Middlewares/RegisterGlobalsMiddlewareTest.php @@ -17,13 +17,13 @@ use Tests\TestCase; class RegisterGlobalsMiddlewareTest extends TestCase { /** @var Twig Twig templating component */ - protected $view; + private $view; /** @var ServerRequestInterface&MockObject */ - protected $request; + private $request; /** @var RequestHandlerInterface&MockObject */ - protected $handler; + private $handler; protected function setUp(): void { diff --git a/tests/ViewFunctions/TranslateTest.php b/tests/ViewFunctions/TranslateTest.php index 998fe73..845da61 100644 --- a/tests/ViewFunctions/TranslateTest.php +++ b/tests/ViewFunctions/TranslateTest.php @@ -15,7 +15,7 @@ use Tests\TestCase; class TranslateTest extends TestCase { /** @var Translator Translator component */ - protected $translator; + private $translator; public function setUp(): void {