Skip to content

Conversation

@ycrao
Copy link
Contributor

@ycrao ycrao commented Dec 25, 2025

fix return Bad Middleware when using class string name in router.

$router->group('', function(Router $router) use ($app) {

	$router->get('/', function() use ($app) {
		$app->render('welcome', ['message' => 'some message...']);
	});
}, [ SecurityHeadersMiddleware::class ]);

then run php runway routes in terminal.

before fix:

Routes
+----------------------------------------------+--------------------+-------+----------+----------------+
| Pattern                                      | Methods            | Alias | Streamed | Middleware     |
+----------------------------------------------+--------------------+-------+----------+----------------+
| /                                            | GET, HEAD, OPTIONS |       | No       | Bad Middleware |

after fix:

+----------------------------------------------+--------------------+-------+----------+------------------------------------------------+
| Pattern                                      | Methods            | Alias | Streamed | Middleware                                     |
+----------------------------------------------+--------------------+-------+----------+------------------------------------------------+
| /                                            | GET, HEAD, OPTIONS |       | No       | SecurityHeadersMiddleware                      |

fix return Bad Middleware when using class string name
@n0nag0n
Copy link
Collaborator

n0nag0n commented Dec 25, 2025

Hey there! Thanks for the contribution! Looks like there's a unit test to fix and then I can merge this in. Thanks for that!

@ycrao
Copy link
Contributor Author

ycrao commented Dec 26, 2025

I have fixed the route test cases, but it seems that in testing with PHP 8.4 and later versions, got some other error not caused by this.

Run composer test-ci
PHPUnit 9.6.31 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.4.15
Configuration: /home/runner/work/core/core/phpunit.xml
Random Seed:   1766723030

...............................................................  63 / 425 ( 14%)
............................................................... 126 / 425 ( 29%)
............................................................... 189 / 425 ( 44%)
..................E

Time: 00:00.089, Memory: 12.00 MB

There was 1 error:

1) tests\commands\ControllerCommandTest::testControllerAlreadyExists
ErrorException: flight\commands\AbstractBaseCommand::addOption(): Implicitly marking parameter $mode as nullable is deprecated, the explicit nullable type must be used instead

/home/runner/work/core/core/vendor/flightphp/runway/src/commands/AbstractBaseCommand.php:90
/home/runner/work/core/core/flight/commands/ControllerCommand.php:11
/home/runner/work/core/core/flight/core/Loader.php:205
/home/runner/work/core/core/tests/commands/ControllerCommandTest.php:70
/home/runner/work/core/core/vendor/bin/phpunit:122

ERRORS!
Tests: 208, Assertions: 411, Errors: 1.
Script phpunit handling the test-ci event returned with error code 2
Error: Process completed with exit code 2.

@n0nag0n n0nag0n merged commit b26598f into flightphp:master Dec 27, 2025
7 checks passed
@n0nag0n
Copy link
Collaborator

n0nag0n commented Dec 27, 2025

Thanks for your help with this and runway! I'll version this in a little bit!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants