5
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Phalcon2系で独自Validationのエラーが出る時の対策

Last updated at Posted at 2015-05-14

Phalcon1系から2系にそのまま移行しようとすると、
独自バリデーションインターフェースでこんなエラーが出ちゃう。

Declaration of MyValidation::validate() must be compatible with Phalcon\Validation\Validator::validate(Phalcon\Validation $validation, $attribute)
Phalcon1系での書き方
use Phalcon\Validation\Validator;
use Phalcon\Validation\ValidatorInterface;

class MyValidation extends Validator implements ValidatorInterface
{
    public function validate($validator, $attribute)
    {
        ...
    }
}

2系ではこうしないとダメらしい…

Phalcon2系での書き方
use Phalcon\Validation\Validator;
use Phalcon\Validation\ValidatorInterface;

class MyValidation extends Validator implements ValidatorInterface
{
    public function validate(\Phalcon\Validation $validator, $attribute)
    {
        ...
    }
}

投稿現在(2015/05/14)では、
公式ドキュメントも1系の書き方で記載されているので要注意!

5
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?