driade / phpfmt8

PHP formatter for Sublime Text 4, with PHP 8 support.
BSD 3-Clause "New" or "Revised" License
46 stars 2 forks source link

static function #73

Closed mpmont closed 5 months ago

mpmont commented 5 months ago

Hi there.

In the current version this code:

$routes->group('careers', static function ($routes) {
    $routes->get('/', 'Users\Careers::index');
    $routes->get('create', 'Users\Careers::manage');
    $routes->get('update/(:num)', 'Users\Careers::manage/$1');
    $routes->post('save', 'Users\Careers::save');
});

Is being changed to

$routes->group('careers', function(static $routes) {
    $routes->get('/', 'Users\Careers::index');
    $routes->get('create', 'Users\Careers::manage');
    $routes->get('update/(:num)', 'Users\Careers::manage/$1');
    $routes->post('save', 'Users\Careers::save');
});
driade commented 5 months ago

Thank you!

Yes, this should be a bug to fix, but, for me to know, what would be here the benefit using "static function"? I've never seen this before. Which framework is it?

mpmont commented 5 months ago

Don't know about the benefit, but this is Codeigniter 4. And its how its documented to define routes with closures

More on that here https://codeigniter.com/user_guide/incoming/routing.html#using-closures

driade commented 5 months ago

Hi, this should be fixed in the latest release (it may take a few ours to update). Thanks!