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.

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

报告相同问题?

悬赏问题

  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 CSS实现渐隐虚线框
  • ¥15 有没有帮写代码做实验仿真的
  • ¥30 vmware exsi重置后登不上
  • ¥15 易盾点选的cb参数怎么解啊
  • ¥15 MATLAB运行显示错误,如何解决?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
  • ¥20 yolov5自定义Prune报错,如何解决?