From 7b81af9a1999ce80fdb40fbdd3b2794fd65833c6 Mon Sep 17 00:00:00 2001 From: Caio Fernandes Date: Fri, 9 Oct 2026 00:35:13 -0300 Subject: [PATCH] fix: correct StaticFileManager::registerDirectory() call + PSR-12 - Application::staticFiles() passed $this to StaticFileManager::registerDirectory(), but the method was decoupled from core (core-routing) and now expects (routePrefix, physicalPath, options). Removes the stale $this argument (fixes PHPStan level 9 errors). - Auto-fix PSR-12 multi-line function call violations in 4 test files. --- src/Core/Application.php | 2 +- tests/Core/ContainerTest.php | 9 ++++++--- tests/Middleware/Performance/RateLimitMiddlewareTest.php | 9 ++++++--- tests/Middleware/SimpleLoadShedderTest.php | 9 ++++++--- tests/Support/StrTest.php | 9 ++++++--- 5 files changed, 25 insertions(+), 13 deletions(-) diff --git a/src/Core/Application.php b/src/Core/Application.php index 7d0bb74..86e3ef3 100644 --- a/src/Core/Application.php +++ b/src/Core/Application.php @@ -632,7 +632,7 @@ public function staticFiles( array $options = [] ): self { // Registra cada arquivo encontrado como uma rota individual - StaticFileManager::registerDirectory($routePrefix, $physicalPath, $this, $options); + StaticFileManager::registerDirectory($routePrefix, $physicalPath, $options); return $this; } diff --git a/tests/Core/ContainerTest.php b/tests/Core/ContainerTest.php index 2d69b6a..e08fdc8 100644 --- a/tests/Core/ContainerTest.php +++ b/tests/Core/ContainerTest.php @@ -36,9 +36,12 @@ class ContainerTest extends TestCase protected function setUp(): void { // Suppress E_USER_DEPRECATED from the deprecated Core\Container class under test - set_error_handler(static function (int $errno): bool { - return $errno === E_USER_DEPRECATED; - }, E_ALL); + set_error_handler( + static function (int $errno): bool { + return $errno === E_USER_DEPRECATED; + }, + E_ALL + ); // Reset singleton instance for isolated testing $this->resetContainerSingleton(); diff --git a/tests/Middleware/Performance/RateLimitMiddlewareTest.php b/tests/Middleware/Performance/RateLimitMiddlewareTest.php index df6aa6d..aea811d 100644 --- a/tests/Middleware/Performance/RateLimitMiddlewareTest.php +++ b/tests/Middleware/Performance/RateLimitMiddlewareTest.php @@ -15,9 +15,12 @@ class RateLimitMiddlewareTest extends TestCase protected function setUp(): void { // Suppress E_USER_DEPRECATED from the deprecated RateLimitMiddleware class under test - set_error_handler(static function (int $errno): bool { - return $errno === E_USER_DEPRECATED; - }, E_ALL); + set_error_handler( + static function (int $errno): bool { + return $errno === E_USER_DEPRECATED; + }, + E_ALL + ); } protected function tearDown(): void diff --git a/tests/Middleware/SimpleLoadShedderTest.php b/tests/Middleware/SimpleLoadShedderTest.php index 310788f..18c1276 100644 --- a/tests/Middleware/SimpleLoadShedderTest.php +++ b/tests/Middleware/SimpleLoadShedderTest.php @@ -17,9 +17,12 @@ class SimpleLoadShedderTest extends TestCase protected function setUp(): void { // Suppress E_USER_DEPRECATED from the deprecated LoadShedder class under test - set_error_handler(static function (int $errno): bool { - return $errno === E_USER_DEPRECATED; - }, E_ALL); + set_error_handler( + static function (int $errno): bool { + return $errno === E_USER_DEPRECATED; + }, + E_ALL + ); $this->loadShedder = new LoadShedder(5, 60); // 5 requests per 60 seconds } diff --git a/tests/Support/StrTest.php b/tests/Support/StrTest.php index de4d545..0b76004 100644 --- a/tests/Support/StrTest.php +++ b/tests/Support/StrTest.php @@ -10,9 +10,12 @@ class StrTest extends TestCase protected function setUp(): void { // Suppress E_USER_DEPRECATED from deprecated Str methods under test - set_error_handler(static function (int $errno): bool { - return $errno === E_USER_DEPRECATED; - }, E_ALL); + set_error_handler( + static function (int $errno): bool { + return $errno === E_USER_DEPRECATED; + }, + E_ALL + ); } protected function tearDown(): void