yii2:Call 到 denyCallback 中未定义的方法 Closure::allows()

yii2:Call to undefined method Closure::allows() in denyCallback

我使用 Yii2 框架 这是我在 ShippingController

中的行为函数
  public function behaviors()
        {
        return [
            'access' => [
                'class' => \yii\filters\AccessControl::className(),
                'rules' => [
                    // deny all POST requests
//                        [
//                        'actions' => ['index', 'create'],
//                        'allow' => TRUE,
//                    ],
                        [
                        'actions' => ['index', 'create', 'init'],
                        'allow' => true,
                        'roles' => ['?'],
                        'matchCallback' => function ($rule, $action)
                            {
                            return $action->controller->redirect('action');
                            }
                    ],
                    'denyCallback' => function ($rule, $action)
                        {
                        return $action->controller->redirect('not');
                        }
                // everything else is denied
                ],
            ],
        ];

        }

matchCallback 运行良好,但

denyCallback 我有这个错误:

错误 调用未定义的方法 Closure::allows()

我的问题是什么???!

denyCallback 元素移出规则数组
它需要与 classrules

处于同一水平