From 85d2f82f771e6d5d4187e1bcf56053f6ad0ea41b Mon Sep 17 00:00:00 2001 From: fadrian06 Date: Tue, 23 Jun 2026 12:48:02 -0400 Subject: [PATCH 01/12] autoload reworked - removed autoload-dev.classmap - normalize Tests/* namespace to tests - rename tests/server-v2 to tests/server_v2 - remove tests/phpunit_autoload.php - update tests files namespaces - update tests/server/index.php and tests/server_v2/index.php to use composer autoloader - extract tests/server_v2/AuthCheck.php --- composer.json | 12 +- phpunit.xml.dist | 3 +- tests/EventSystemTest.php | 2 +- .../ExampleClass.php | 2 + .../FlightTest.php | 3 +- tests/phpunit_autoload.php | 9 - tests/server-v2/index.php | 243 ------------------ tests/server/AuthCheck.php | 2 +- tests/server/LayoutMiddleware.php | 2 +- tests/server/OverwriteBodyMiddleware.php | 2 +- tests/server/Pascal_Snake_Case.php | 2 +- tests/server/index.php | 12 +- tests/server_v2/AuthCheck.php | 15 ++ tests/server_v2/index.php | 228 ++++++++++++++++ tests/{server-v2 => server_v2}/template.phtml | 0 15 files changed, 260 insertions(+), 277 deletions(-) rename tests/{named-arguments => named_arguments}/ExampleClass.php (78%) rename tests/{named-arguments => named_arguments}/FlightTest.php (98%) delete mode 100644 tests/phpunit_autoload.php delete mode 100644 tests/server-v2/index.php create mode 100644 tests/server_v2/AuthCheck.php create mode 100644 tests/server_v2/index.php rename tests/{server-v2 => server_v2}/template.phtml (100%) diff --git a/composer.json b/composer.json index 70a09ca5..19e57f5d 100644 --- a/composer.json +++ b/composer.json @@ -32,16 +32,8 @@ ] }, "autoload-dev": { - "classmap": [ - "tests/classes/" - ], "psr-4": { - "Tests\\PHP8\\": [ - "tests/named-arguments" - ], - "Tests\\Server\\": "tests/server", - "Tests\\ServerV2\\": "tests/server-v2", - "tests\\groupcompactsyntax\\": "tests/groupcompactsyntax" + "tests\\": "tests" } }, "require-dev": { @@ -83,7 +75,7 @@ ], "test-server-v2": [ "echo \"Running Test Server\"", - "@php -S localhost:8000 -t tests/server-v2" + "@php -S localhost:8000 -t tests/server_v2" ], "test-coverage:win": [ "del clover.xml", diff --git a/phpunit.xml.dist b/phpunit.xml.dist index b890bb7f..ddbd446a 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -2,7 +2,6 @@ tests/ - tests/named-arguments/ + tests/named_arguments/ diff --git a/tests/EventSystemTest.php b/tests/EventSystemTest.php index 9a229b6e..7af48f4f 100644 --- a/tests/EventSystemTest.php +++ b/tests/EventSystemTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace flight\tests; +namespace tests; use Flight; use PHPUnit\Framework\TestCase; diff --git a/tests/named-arguments/ExampleClass.php b/tests/named_arguments/ExampleClass.php similarity index 78% rename from tests/named-arguments/ExampleClass.php rename to tests/named_arguments/ExampleClass.php index 508068c1..95550476 100644 --- a/tests/named-arguments/ExampleClass.php +++ b/tests/named_arguments/ExampleClass.php @@ -2,6 +2,8 @@ declare(strict_types=1); +namespace tests\named_arguments; + // phpcs:ignore PSR1.Classes.ClassDeclaration.MissingNamespace class ExampleClass { diff --git a/tests/named-arguments/FlightTest.php b/tests/named_arguments/FlightTest.php similarity index 98% rename from tests/named-arguments/FlightTest.php rename to tests/named_arguments/FlightTest.php index 6593450d..9053b02f 100644 --- a/tests/named-arguments/FlightTest.php +++ b/tests/named_arguments/FlightTest.php @@ -2,10 +2,9 @@ declare(strict_types=1); -namespace Tests\PHP8; +namespace tests\named_arguments; use DateTimeImmutable; -use ExampleClass; use Flight; use flight\Container; use flight\Engine; diff --git a/tests/phpunit_autoload.php b/tests/phpunit_autoload.php deleted file mode 100644 index 5bf47dad..00000000 --- a/tests/phpunit_autoload.php +++ /dev/null @@ -1,9 +0,0 @@ -Middleware text: You are not authorized to access this route!'; - } - } - } -} - -namespace { - - use Tests\ServerV2\AuthCheck; - - require_once __DIR__ . '/../phpunit_autoload.php'; - - Flight::set('flight.content_length', false); - Flight::set('flight.views.path', './'); - Flight::set('flight.views.extension', '.phtml'); - // This enables the old functionality of Flight output buffering - Flight::set('flight.v2.output_buffering', true); - - // Test 1: Root route - Flight::route('/', function () { - echo 'Route text: Root route works!'; - - if (Flight::request()->query['redirected']) { - echo '
Redirected from /redirect route successfully!'; - } - }); - - Flight::route('/querytestpath', function () { - echo 'Route text: This ir query route
'; - echo 'I got such query parameters:
';
-        print_r(Flight::request()->query);
-        echo '
'; - }, false, 'querytestpath'); - - // Test 2: Simple route - Flight::route('/test', function () { - echo 'Route text: Test route works!'; - }); - - // Test 3: Route with parameter - Flight::route('/user/@name', function ($name) { - echo "Route text: Hello, $name!"; - }); - - Flight::route('POST /postpage', function () { - echo 'Route text: THIS IS POST METHOD PAGE'; - }, false, 'postpage'); - - // Test 4: Grouped routes - Flight::group('/group', function () { - Flight::route('/test', function () { - echo 'Route text: Group test route works!'; - }); - - Flight::route('/user/@name', function ($name) { - echo "Route text: There is variable called name and it is $name"; - }); - - Flight::group('/group1', function () { - Flight::group('/group2', function () { - Flight::group('/group3', function () { - Flight::group('/group4', function () { - Flight::group('/group5', function () { - Flight::group('/group6', function () { - Flight::group('/group7', function () { - Flight::group('/group8', function () { - Flight::route('/final_group', function () { - echo 'Mega Group test route works!'; - }, false, 'final_group'); - }); - }); - }); - }); - }); - }); - }); - }); - }); - - // Test 5: Route alias - Flight::route('/alias', function () { - echo 'Route text: Alias route works!'; - }, false, 'aliasroute'); - - $middle = new AuthCheck(); - - // Test 6: Route with middleware - Flight::route('/protected', function () { - echo 'Route text: Protected route works!'; - })->addMiddleware([$middle]); - - // Test 7: Route with template - Flight::route('/template/@name', function ($name) { - Flight::render('template.phtml', ['name' => $name]); - }); - - // Test 8: Throw an error - Flight::route('/error', function () { - trigger_error('This is a successful error'); - }); - - // Test 9: JSON output (should not output any other html) - Flight::route('/json', function () { - echo "\n\n\n\n\n"; - Flight::json(['message' => 'JSON renders successfully!']); - echo "\n\n\n\n\n"; - }); - - // Test 13: JSONP output (should not output any other html) - Flight::route('/jsonp', function () { - echo "\n\n\n\n\n"; - Flight::jsonp(['message' => 'JSONP renders successfully!'], 'jsonp'); - echo "\n\n\n\n\n"; - }); - - Flight::route('/json-halt', function () { - Flight::jsonHalt(['message' => 'JSON rendered and halted successfully with no other body content!']); - }); - - // Test 10: Halt - Flight::route('/halt', function () { - Flight::halt(400, 'Halt worked successfully'); - }); - - // Test 11: Redirect - Flight::route('/redirect', function () { - Flight::redirect('/?redirected=1'); - }); - - Flight::set('flight.views.path', './'); - - Flight::map('error', function (Throwable $error) { - echo "

An error occurred, mapped error method worked, error below

"; - echo '
';
-        echo str_replace(getenv('PWD'), "***CLASSIFIED*****", $error->getTraceAsString());
-        echo "
"; - echo "Go back"; - }); - - Flight::map('notFound', function () { - echo 'Route text: The requested URL was not found'; - echo "Go back"; - }); - - echo ' - - '; - - Flight::before('start', function () { - echo '
'; - }); - - Flight::after('start', function () { - echo '
'; - echo '
'; - echo "Request information
";
-        print_r(Flight::request());
-        echo "
"; - echo "
"; - }); - - Flight::start(); -} diff --git a/tests/server/AuthCheck.php b/tests/server/AuthCheck.php index 79e8f677..c042c1b3 100644 --- a/tests/server/AuthCheck.php +++ b/tests/server/AuthCheck.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Tests\Server; +namespace tests\server; class AuthCheck { diff --git a/tests/server/LayoutMiddleware.php b/tests/server/LayoutMiddleware.php index 150985bd..01058c0b 100644 --- a/tests/server/LayoutMiddleware.php +++ b/tests/server/LayoutMiddleware.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Tests\Server; +namespace tests\server; use Flight; diff --git a/tests/server/OverwriteBodyMiddleware.php b/tests/server/OverwriteBodyMiddleware.php index 98e84685..6a3dfa8a 100644 --- a/tests/server/OverwriteBodyMiddleware.php +++ b/tests/server/OverwriteBodyMiddleware.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Tests\Server; +namespace tests\server; use Flight; diff --git a/tests/server/Pascal_Snake_Case.php b/tests/server/Pascal_Snake_Case.php index d80ed416..df9a66ff 100644 --- a/tests/server/Pascal_Snake_Case.php +++ b/tests/server/Pascal_Snake_Case.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Tests\Server; +namespace tests\server; class Pascal_Snake_Case // phpcs:ignore { diff --git a/tests/server/index.php b/tests/server/index.php index 6bb9dcac..c34822ef 100644 --- a/tests/server/index.php +++ b/tests/server/index.php @@ -7,10 +7,12 @@ use flight\database\PdoWrapper; use tests\classes\Container; use tests\classes\ContainerDefault; -use Tests\Server\AuthCheck; -use Tests\Server\LayoutMiddleware; -use Tests\Server\OverwriteBodyMiddleware; -use Tests\Server\Pascal_Snake_Case; +use tests\server\AuthCheck; +use tests\server\LayoutMiddleware; +use tests\server\OverwriteBodyMiddleware; +use tests\server\Pascal_Snake_Case; + +require_once __DIR__ . '/../../vendor/autoload.php'; /* * This is the test file where we can open up a quick test server and make @@ -19,8 +21,6 @@ * @author Kristaps Muižnieks https://github.com/krmu */ -require_once __DIR__ . '/../phpunit_autoload.php'; - Flight::set('flight.content_length', false); Flight::set('flight.views.path', './'); Flight::set('flight.views.extension', '.phtml'); diff --git a/tests/server_v2/AuthCheck.php b/tests/server_v2/AuthCheck.php new file mode 100644 index 00000000..6ae651de --- /dev/null +++ b/tests/server_v2/AuthCheck.php @@ -0,0 +1,15 @@ +Middleware text: You are not authorized to access this route!'; + } + } +} diff --git a/tests/server_v2/index.php b/tests/server_v2/index.php new file mode 100644 index 00000000..edd0cb68 --- /dev/null +++ b/tests/server_v2/index.php @@ -0,0 +1,228 @@ +Route text: Root route works!'; + + if (Flight::request()->query['redirected']) { + echo '
Redirected from /redirect route successfully!'; + } +}); + +Flight::route('/querytestpath', function () { + echo 'Route text: This ir query route
'; + echo 'I got such query parameters:
';
+    print_r(Flight::request()->query);
+    echo '
'; +}, false, 'querytestpath'); + +// Test 2: Simple route +Flight::route('/test', function () { + echo 'Route text: Test route works!'; +}); + +// Test 3: Route with parameter +Flight::route('/user/@name', function ($name) { + echo "Route text: Hello, $name!"; +}); + +Flight::route('POST /postpage', function () { + echo 'Route text: THIS IS POST METHOD PAGE'; +}, false, 'postpage'); + +// Test 4: Grouped routes +Flight::group('/group', function () { + Flight::route('/test', function () { + echo 'Route text: Group test route works!'; + }); + + Flight::route('/user/@name', function ($name) { + echo "Route text: There is variable called name and it is $name"; + }); + + Flight::group('/group1', function () { + Flight::group('/group2', function () { + Flight::group('/group3', function () { + Flight::group('/group4', function () { + Flight::group('/group5', function () { + Flight::group('/group6', function () { + Flight::group('/group7', function () { + Flight::group('/group8', function () { + Flight::route('/final_group', function () { + echo 'Mega Group test route works!'; + }, false, 'final_group'); + }); + }); + }); + }); + }); + }); + }); + }); +}); + +// Test 5: Route alias +Flight::route('/alias', function () { + echo 'Route text: Alias route works!'; +}, false, 'aliasroute'); + +$middle = new AuthCheck(); + +// Test 6: Route with middleware +Flight::route('/protected', function () { + echo 'Route text: Protected route works!'; +})->addMiddleware([$middle]); + +// Test 7: Route with template +Flight::route('/template/@name', function ($name) { + Flight::render('template.phtml', ['name' => $name]); +}); + +// Test 8: Throw an error +Flight::route('/error', function () { + trigger_error('This is a successful error'); +}); + +// Test 9: JSON output (should not output any other html) +Flight::route('/json', function () { + echo "\n\n\n\n\n"; + Flight::json(['message' => 'JSON renders successfully!']); + echo "\n\n\n\n\n"; +}); + +// Test 13: JSONP output (should not output any other html) +Flight::route('/jsonp', function () { + echo "\n\n\n\n\n"; + Flight::jsonp(['message' => 'JSONP renders successfully!'], 'jsonp'); + echo "\n\n\n\n\n"; +}); + +Flight::route('/json-halt', function () { + Flight::jsonHalt(['message' => 'JSON rendered and halted successfully with no other body content!']); +}); + +// Test 10: Halt +Flight::route('/halt', function () { + Flight::halt(400, 'Halt worked successfully'); +}); + +// Test 11: Redirect +Flight::route('/redirect', function () { + Flight::redirect('/?redirected=1'); +}); + +Flight::set('flight.views.path', './'); + +Flight::map('error', function (Throwable $error) { + echo "

An error occurred, mapped error method worked, error below

"; + echo '
';
+    echo str_replace(getenv('PWD'), "***CLASSIFIED*****", $error->getTraceAsString());
+    echo "
"; + echo "Go back"; +}); + +Flight::map('notFound', function () { + echo 'Route text: The requested URL was not found'; + echo "Go back"; +}); + +echo ' + +'; + +Flight::before('start', function () { + echo '
'; +}); + +Flight::after('start', function () { + echo '
'; + echo '
'; + echo "Request information
";
+    print_r(Flight::request());
+    echo "
"; + echo "
"; +}); + +Flight::start(); diff --git a/tests/server-v2/template.phtml b/tests/server_v2/template.phtml similarity index 100% rename from tests/server-v2/template.phtml rename to tests/server_v2/template.phtml From 90a72aef7c1e4640db9db1efc797bc821f8bbc21 Mon Sep 17 00:00:00 2001 From: fadrian06 Date: Tue, 23 Jun 2026 13:00:49 -0400 Subject: [PATCH 02/12] move Flight to a classmap --- composer.json | 3 +++ flight/autoload.php | 1 - 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 19e57f5d..f32c0ffc 100644 --- a/composer.json +++ b/composer.json @@ -27,6 +27,9 @@ "ext-json": "*" }, "autoload": { + "classmap": [ + "flight/Flight.php" + ], "files": [ "flight/autoload.php" ] diff --git a/flight/autoload.php b/flight/autoload.php index 0a31c864..3a7ea5a0 100644 --- a/flight/autoload.php +++ b/flight/autoload.php @@ -4,7 +4,6 @@ use flight\core\Loader; -require_once __DIR__ . '/Flight.php'; require_once __DIR__ . '/core/Loader.php'; Loader::autoload(true, [dirname(__DIR__)]); From 1a37f91b999d8ac6986eb8533c3c2b8807556315 Mon Sep 17 00:00:00 2001 From: fadrian06 Date: Tue, 23 Jun 2026 13:01:13 -0400 Subject: [PATCH 03/12] add flight\ psr-4 autoloader --- composer.json | 5 ++++- flight/autoload.php | 2 -- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index f32c0ffc..41ec59eb 100644 --- a/composer.json +++ b/composer.json @@ -32,7 +32,10 @@ ], "files": [ "flight/autoload.php" - ] + ], + "psr-4": { + "flight\\": "flight" + } }, "autoload-dev": { "psr-4": { diff --git a/flight/autoload.php b/flight/autoload.php index 3a7ea5a0..fd17f6af 100644 --- a/flight/autoload.php +++ b/flight/autoload.php @@ -4,6 +4,4 @@ use flight\core\Loader; -require_once __DIR__ . '/core/Loader.php'; - Loader::autoload(true, [dirname(__DIR__)]); From 921c51a5d6abba83fdfc2a36cbd78d580d77c25e Mon Sep 17 00:00:00 2001 From: fadrian06 Date: Tue, 23 Jun 2026 13:55:08 -0400 Subject: [PATCH 04/12] use is_iterable in Loader::register --- flight/core/Loader.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flight/core/Loader.php b/flight/core/Loader.php index 1824b9c7..d2a5a8bb 100644 --- a/flight/core/Loader.php +++ b/flight/core/Loader.php @@ -215,7 +215,7 @@ public static function loadClass(string $class): void */ public static function addDirectory($dir): void { - if (\is_array($dir) || \is_object($dir)) { + if (is_iterable($dir)) { foreach ($dir as $value) { self::addDirectory($value); } From 9aab65b7f6333419cec95006abde4464b6235acb Mon Sep 17 00:00:00 2001 From: fadrian06 Date: Tue, 23 Jun 2026 13:55:30 -0400 Subject: [PATCH 05/12] fix Loader::register docblock --- flight/core/Loader.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/flight/core/Loader.php b/flight/core/Loader.php index d2a5a8bb..cf0ff597 100644 --- a/flight/core/Loader.php +++ b/flight/core/Loader.php @@ -48,10 +48,9 @@ class Loader * Registers a class. * * @param string $name Registry name - * @param class-string|Closure(): T $class Class name or function to instantiate class + * @param class-string|(Closure(): T) $class Class name or function to instantiate class * @param array $params Class initialization parameters - * @param ?Closure(T $instance): void $callback $callback Function to call after object instantiation - * + * @param null|(Closure(T $instance): void) $callback $callback Function to call after object instantiation * @template T of object */ public function register(string $name, $class, array $params = [], ?callable $callback = null): void From db343815a3abc9968774435e29f44a3f1ee0d752 Mon Sep 17 00:00:00 2001 From: fadrian06 Date: Tue, 23 Jun 2026 13:55:45 -0400 Subject: [PATCH 06/12] normalize dirs --- flight/core/Loader.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/flight/core/Loader.php b/flight/core/Loader.php index cf0ff597..36093cb6 100644 --- a/flight/core/Loader.php +++ b/flight/core/Loader.php @@ -218,8 +218,10 @@ public static function addDirectory($dir): void foreach ($dir as $value) { self::addDirectory($value); } - } elseif (\is_string($dir)) { - if (!\in_array($dir, self::$dirs, true)) { + } elseif (is_string($dir)) { + $dir = str_replace(['/', '\\'], DIRECTORY_SEPARATOR, $dir); + + if (!in_array($dir, self::$dirs, true)) { self::$dirs[] = $dir; } } From 47a3702927b756a4bb9a50b179c600df2c94664d Mon Sep 17 00:00:00 2001 From: fadrian06 Date: Tue, 23 Jun 2026 13:56:08 -0400 Subject: [PATCH 07/12] refactor LoaderTest --- flight/autoload.php | 4 ++-- tests/LoaderTest.php | 39 ++++++++++++++++++--------------------- 2 files changed, 20 insertions(+), 23 deletions(-) diff --git a/flight/autoload.php b/flight/autoload.php index fd17f6af..0c43ffaa 100644 --- a/flight/autoload.php +++ b/flight/autoload.php @@ -2,6 +2,6 @@ declare(strict_types=1); -use flight\core\Loader; +// use flight\core\Loader; -Loader::autoload(true, [dirname(__DIR__)]); +// Loader::autoload(true, [dirname(__DIR__)]); diff --git a/tests/LoaderTest.php b/tests/LoaderTest.php index de37efa8..efe6c6d1 100644 --- a/tests/LoaderTest.php +++ b/tests/LoaderTest.php @@ -4,10 +4,12 @@ namespace tests; +use Closure; use flight\core\Loader; use tests\classes\Factory; use tests\classes\User; use PHPUnit\Framework\TestCase; +use ReflectionClass; use tests\classes\TesterClass; class LoaderTest extends TestCase @@ -17,7 +19,6 @@ class LoaderTest extends TestCase protected function setUp(): void { $this->loader = new Loader(); - $this->loader->autoload(true, __DIR__ . '/classes'); } // Autoload a class @@ -85,7 +86,7 @@ public function testSharedInstance(): void // Gets an object from a factory method public function testRegisterUsingCallable(): void { - $this->loader->register('e', ['\tests\classes\Factory', 'create']); + $this->loader->register('e', Closure::fromCallable([Factory::class, 'create'])); $obj = $this->loader->load('e'); @@ -140,29 +141,25 @@ public function testNewInstance6Params(): void public function testAddDirectoryAsArray(): void { - $loader = new class extends Loader { - public function getDirectories() - { - return self::$dirs; - } - }; - $loader->addDirectory([__DIR__ . '/classes']); - self::assertEquals([ - dirname(__DIR__), - __DIR__ . '/classes' - ], $loader->getDirectories()); + $loader = new Loader(); + $loader::addDirectory([__DIR__ . '/classes']); + + $dirsProperty = (new ReflectionClass(Loader::class))->getProperty('dirs'); + $dirsProperty->setAccessible(true); + $dirs = $dirsProperty->getValue($loader); + + self::assertEquals([__DIR__ . DIRECTORY_SEPARATOR . 'classes'], $dirs); } public function testV2ClassLoading(): void { - $loader = new class extends Loader { - public static function getV2ClassLoading() - { - return self::$v2ClassLoading; - } - }; - $this->assertTrue($loader::getV2ClassLoading()); + $loader = new Loader(); + + $v2ClassLoadingProperty = (new ReflectionClass(Loader::class))->getProperty('v2ClassLoading'); + $v2ClassLoadingProperty->setAccessible(true); + + $this->assertTrue($v2ClassLoadingProperty->getValue($loader)); $loader::setV2ClassLoading(false); - $this->assertFalse($loader::getV2ClassLoading()); + $this->assertFalse($v2ClassLoadingProperty->getValue($loader)); } } From cf553d36d4ea03678340dfcef0a77da2e2b07bec Mon Sep 17 00:00:00 2001 From: fadrian06 Date: Tue, 23 Jun 2026 13:57:57 -0400 Subject: [PATCH 08/12] remove flight/autoload.php --- composer.json | 3 --- flight/Flight.php | 2 -- flight/autoload.php | 7 ------- index.php | 3 +-- phpunit.xml.dist | 3 --- 5 files changed, 1 insertion(+), 17 deletions(-) delete mode 100644 flight/autoload.php diff --git a/composer.json b/composer.json index 41ec59eb..b4438480 100644 --- a/composer.json +++ b/composer.json @@ -30,9 +30,6 @@ "classmap": [ "flight/Flight.php" ], - "files": [ - "flight/autoload.php" - ], "psr-4": { "flight\\": "flight" } diff --git a/flight/Flight.php b/flight/Flight.php index c2e9a012..ddb536f3 100644 --- a/flight/Flight.php +++ b/flight/Flight.php @@ -11,8 +11,6 @@ use flight\core\EventDispatcher; use Psr\Container\ContainerInterface; -require_once __DIR__ . '/autoload.php'; - /** * The Flight class is a static representation of the framework. * diff --git a/flight/autoload.php b/flight/autoload.php deleted file mode 100644 index 0c43ffaa..00000000 --- a/flight/autoload.php +++ /dev/null @@ -1,7 +0,0 @@ - flight/ - - flight/autoload.php - From 8ec68173ce8461fec813d8def916c6f0ce71fb44 Mon Sep 17 00:00:00 2001 From: fadrian06 Date: Tue, 23 Jun 2026 14:04:47 -0400 Subject: [PATCH 09/12] validate ->setAccesible --- tests/LoaderTest.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/LoaderTest.php b/tests/LoaderTest.php index efe6c6d1..bffd7d1f 100644 --- a/tests/LoaderTest.php +++ b/tests/LoaderTest.php @@ -145,7 +145,11 @@ public function testAddDirectoryAsArray(): void $loader::addDirectory([__DIR__ . '/classes']); $dirsProperty = (new ReflectionClass(Loader::class))->getProperty('dirs'); - $dirsProperty->setAccessible(true); + + if (PHP_VERSION_ID < 80100) { + $dirsProperty->setAccessible(true); + } + $dirs = $dirsProperty->getValue($loader); self::assertEquals([__DIR__ . DIRECTORY_SEPARATOR . 'classes'], $dirs); @@ -156,7 +160,10 @@ public function testV2ClassLoading(): void $loader = new Loader(); $v2ClassLoadingProperty = (new ReflectionClass(Loader::class))->getProperty('v2ClassLoading'); - $v2ClassLoadingProperty->setAccessible(true); + + if (PHP_VERSION_ID < 80100) { + $v2ClassLoadingProperty->setAccessible(true); + } $this->assertTrue($v2ClassLoadingProperty->getValue($loader)); $loader::setV2ClassLoading(false); From ee9b5f20823e01874255ee146c2d4fbc8f933c27 Mon Sep 17 00:00:00 2001 From: fadrian06 Date: Tue, 23 Jun 2026 14:08:39 -0400 Subject: [PATCH 10/12] reset v2ClassLoading --- tests/LoaderTest.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/LoaderTest.php b/tests/LoaderTest.php index bffd7d1f..cbb916a5 100644 --- a/tests/LoaderTest.php +++ b/tests/LoaderTest.php @@ -21,6 +21,11 @@ protected function setUp(): void $this->loader = new Loader(); } + protected function tearDown(): void + { + Loader::setV2ClassLoading(true); + } + // Autoload a class public function testAutoload(): void { From 770d246e29460ee3df6ef6574393a7629b36d968 Mon Sep 17 00:00:00 2001 From: fadrian06 Date: Tue, 23 Jun 2026 14:09:34 -0400 Subject: [PATCH 11/12] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- tests/server_v2/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/server_v2/index.php b/tests/server_v2/index.php index edd0cb68..63bd73a8 100644 --- a/tests/server_v2/index.php +++ b/tests/server_v2/index.php @@ -29,7 +29,7 @@ }); Flight::route('/querytestpath', function () { - echo 'Route text: This ir query route
'; + echo 'Route text: This is query route
'; echo 'I got such query parameters:
';
     print_r(Flight::request()->query);
     echo '
'; From d58cbacda1ce06f2c3690a0c97ded22e18f170d9 Mon Sep 17 00:00:00 2001 From: fadrian06 Date: Wed, 24 Jun 2026 20:50:21 -0400 Subject: [PATCH 12/12] restore and improve custom autoloader --- flight/autoload.php | 14 ++++++++++++++ index.php | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 flight/autoload.php diff --git a/flight/autoload.php b/flight/autoload.php new file mode 100644 index 00000000..e4017284 --- /dev/null +++ b/flight/autoload.php @@ -0,0 +1,14 @@ +