When using the Console extender's schedule method, it's currently required to pass an instantiated object (either a closure or an invokable class). Based on the docblock and patterns in other extenders, there's an expectation that the method should also accept the ::class syntax for invokable classes. However, this isn't currently supported, leading to unexpected behavior.
(new Extend\Console())
->schedule(Console\ProcessEraseRequests::class, Console\DailySchedule::class);
// Throws error: Call to undefined function Console\DailySchedule()
Steps to Reproduce
Create a new Console extender.
Use the schedule method with the ::class syntax for the callback.
Observe the error when the scheduled command is invoked.
Expected Behavior
(new Extend\Console())
->schedule(Console\ProcessEraseRequests::class, Console\DailySchedule::class);
// Should work, given that Console\DailySchedule is an invokable class
Output of "php flarum info", run this in terminal in your Flarum directory.
Possible Solution
Modify the Console extender to support both instantiated objects and the ::class syntax for invokable classes. This can be done using a similar approach to the Filesystem extender, utilizing the ContainerUtil::wrapCallback method.
Additional Context
This inconsistency can lead to confusion, especially given that other extenders in Flarum handle both closures and invokable classes correctly.
Tests should be added to ensure that this behavior is correctly implemented and maintained in the future.
Current Behavior
When using the Console extender's schedule method, it's currently required to pass an instantiated object (either a closure or an invokable class). Based on the docblock and patterns in other extenders, there's an expectation that the method should also accept the ::class syntax for invokable classes. However, this isn't currently supported, leading to unexpected behavior.
Steps to Reproduce
Console
extender.Expected Behavior
Screenshots
No response
Environment
Output of
php flarum info
Possible Solution
Modify the
Console
extender to support both instantiated objects and the ::class syntax for invokable classes. This can be done using a similar approach to theFilesystem
extender, utilizing theContainerUtil::wrapCallback
method.Additional Context
This inconsistency can lead to confusion, especially given that other extenders in Flarum handle both closures and invokable classes correctly.
Tests should be added to ensure that this behavior is correctly implemented and maintained in the future.