Yii1 - model::validate() 的声明应该与 CModel::validate($attributes = NULL, $clearErrors = true) 兼容

Yii1 - Declaration of model::validate() should be compatible with CModel::validate($attributes = NULL, $clearErrors = true)

当我尝试 运行 控制器内的索引方法时出现此错误:

Declaration of OneTokenAuth::validate() should be compatible with CModel::validate($attributes = NULL, $clearErrors = true)

我的控制器:

<?php

/**
 * Class is used for 
 */
class OneTokenAuthController extends Controller
{
    public function init()
    {
        $this->attachbehavior('restBehavior', new RestBehavior());
        parent::init();
    }

    public function filters()
    {
        return ['accessControl',];
    }

    public function accessRules()
    {
        return [
            [
                'deny',
                'actions' => [
                    'index',
                ],
                'users' =>  ['@']
            ]
        ];

    }

    /**
     * Entry point for validating JWT token
     * If the token is valid, user will be logged in as an admin 
     * and redirected to the admin dashboard
     *
     * @param [string] $t
     * @return void
     */
    function actionIndex($t){

        $token = CHtml::encode(strip_tags($t));

        $auth = new OneTokenAuth($token);

        if(!$auth->verify())
            die('Token is not valid');

        if(!$auth->validate())
            die('Token is not valid');

        $this->redirect('admin/jobs/dashboardNewest');
    }
}

我的模特:

<?php

use Lcobucci\JWT\Builder;
use Lcobucci\JWT\Parser;
use Lcobucci\JWT\Signer\Hmac\Sha256;
use Lcobucci\JWT\Token;
use Lcobucci\JWT\ValidationData as JWTValidation;

/**
 * This is the model class for table "jwt_access_log".
 *
 * The followings are the available columns in table 'jwt_access_log':
 * @property integer $id
 * @property text $token
 * @property integer $token_status
 * @property timespamp $created_at
 */
class OneTokenAuth extends CActiveRecord
{
    const VALID      = 100;
    const UNVERIFIED = 200;
    const NONVALID   = 300;

    private $_singkey;
    private $_token;
    private $_signer;
    private $_data;

    function __construct ($token){

        $this->_singkey = '1234xxxx';
        $this->_signer  = new Sha256();
        $this->_token   =(new Parser())->parse((string) $token);

        $this->_token->getHeaders(); // Retrieves the token header
        $this->_token->getClaims(); // Retrieves the token claims

        $this->_data = new JWTValidation;

        $this->_data->setIssuer('http://example.com');
        $this->_data->setAudience($this->_token->getClaim('iss'));
    }

    public function tableName()
    {
        return 'jwt_access_log';
    }

    public function rules()
    {
        return [
            ['token_status', 'numerical', 'integerOnly' => true],
            ['token', 'length', 'max' => 1024],
            ['created_at', 'safe'],
        ];
    }

     /**
     * @return array customized attribute labels (name=>label)
     */
    public function attributeLabels()
    {
        return array(
            'id'           => 'ID',
            'token'        => 'Token',
            'token_status' => 'Token Status',
            'created_at'   => 'Created At'
        );
    }

    public function verify(){

        if($this->_token->verify($this->_signer, $this->_singkey))
            return true;

        $this->makeLog(self::NONVALID);

        return false;
    }

    public function validate(){

        if($this->_token->validate($this->_data)){
            $this->adminLogin();
            return true;
        }

        $this->makeLog(self::UNVERIFIED);

        return false;

    }

    public function makeLog($status)
    {
        $model = new self();

        var_dump('<pre>', $model, '</pre>');die;
        $model->setAttributes([
            'token'        => $this->_token,
            'token_status' => $status,
        ]);

        $model->save();
    }

    private function adminLogin()
    {

        $this->makeLog(self::VALID);

        $login = new LoginComponent([
            'email'    => 'admin@admin.com',
            'password' => 'u4ci_7aM%pigRe]Vp9B',
        ]);

        $login->login();

    }

}

这是怎么回事?

派生class中的方法必须与父class具有相同的参数,您必须指定参数$attributes$clearErrors

public function validate($attributes=null,$clearErrors=true){
    if($this->_token->validate($this->_data)){
        $this->adminLogin();
        return true;
    }

    $this->makeLog(self::UNVERIFIED);
    return false;
}