flightphp / core

An extensible micro-framework for PHP
https://docs.flightphp.com
MIT License
2.6k stars 407 forks source link

PHP 8 named arguments support #548

Open fadrian06 opened 4 months ago

fadrian06 commented 4 months ago

PHP named arguments helps in some situations for cleaned code, it locks library maintainers to not change the argument names so easily without breaking changes, but php 8 must have support too...

public function test_static_route(): void {
  Flight::request()->url = '/test';

  $route = Flight::route(
    pass_route: true,
    alias: 'testRoute',
    callback: function () {
      echo 'test';
    },
    pattern: '/test'
  );

  self::assertInstanceOf(Route::class, $route);
  self::expectOutputString('test');
  Flight::start();
}
fadrian06 commented 4 months ago

Ok to start the tests for php 8 are excluded from the main suite, I run the tests of that specific class by hand

fadrian06 commented 4 months ago

Calling the app directly instead of __callStatic does make sense because it would help the static analyzer

fadrian06 commented 4 months ago

20240223_015803.jpg

20240223_015800.jpg

fadrian06 commented 4 months ago

I have several ideas to solve it but I don't know how difficult it is to implement it and keep everything working as is.