walkor / webman-framework

webman-framework
116 stars 57 forks source link

Fix #80

Closed imlinfly closed 1 year ago

imlinfly commented 1 year ago

Fix Webman\Route\Route::getCallback(): Return value must be of type ?callable, array returned

Route::get('/index', [IndexController::class, 'index']);
declare (strict_types=1);

namespace app\controller\admin;

use support\Request;
use Throwable;

class IndexController
{
    public function index(Request $request)
    {
        try {
            $ref = new \ReflectionObject($request->route);
            $callback = $ref->getProperty('callback');
            $callback->setAccessible(true);
            $callback = $callback->getValue($request->route);

            var_dump($callback);
            var_dump(is_callable($callback));

            var_dump($request->route->getCallback());
        } catch (Throwable $e) {
            var_dump($e->getMessage());
        }

        return __METHOD__;
    }
}
array(2) {
  [0]=>
  string(36) "app\controller\admin\IndexController"
  [1]=>
  string(5) "index"
}
bool(true)
string(89) "Webman\Route\Route::getCallback(): Return value must be of type ?callable, array returned"
walkor commented 1 year ago

Thanks