doupang1917 2017-06-05 12:58
浏览 19
已采纳

PHPUnit找不到Phalcon的Callback验证器(命名空间问题)

I'm using Phalcon 3.0.3 and PHP 7.0.15-0ubuntu0.16.04.4 with PHPUnit 6.0.8. If I try to use Phalcon\Validation\Validator\Callback I'll always end up with those kind of errros:

1) Test\ConfirmActivityTest::testConfirm Error: Class 'Phalcon\Validation\Validator\Callback' not found

So far the only way I found to solve this problem is to create a copy of that class in my codebase:

namespace Phapp\Validators;

/**
 * A workaround to fix the namespace problem of
 * Phalcon\Validation\Validator\Callback
 *
 */
class CallbackValidator extends \Phalcon\Validation\Validator
{

    /**
     * Executes the validation
     *
     * @param \Phalcon\Validation $validation
     * @param string $field
     * @return bool
     */
    public function validate(\Phalcon\Validation $validation, $field) {}

}

Is there any other workaround I could use to solve this problem? Is it a Phalcon bug?

  • 写回答

1条回答 默认 最新

  • doutongya8378 2017-06-05 19:50
    关注

    Callback validator was added in 3.1.0. Docs were by mistake merged as i remember.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 ghpython这里总是报错而且rhino视图窗口内不显示怎么办
  • ¥15 布尔运算推导,请证明
  • ¥15 有没有人会打学生成绩管理系统呀
  • ¥15 在使用Fiddler和夜神模拟器抓包的时候一直出现443该怎么办啊QAQ搜了好几个笔记都没有解决
  • ¥15 3x7的二维数组A、B、C,A中的任意1个数组元素与B的任意1个数组元素、同时又与C的任意1个数组元素比较,把不同位置出现相同数的比较称为无意义,反之称为有意义,把有意义的比较打印输出。
  • ¥20 预测模型怎么处理原始数据(随机森林)
  • ¥20 请问discuz3.5如何实现插入ckplayer全能播放器功能呢?
  • ¥15 thingsboard代码编译出错误
  • ¥15 博途v18仿真报错怎么解决
  • ¥15 欧姆龙plc枕式包装机 ST编程