今天在使用ThinkPHP时,Validate验证始终失败,定位到如下问题,有朋友碰到过吗?
程序代码
<?php
class Test
{
// 实例
protected static $instance;
public static function make($rules = [], $message = [], $field = [])
{
if (is_null(self::$instance)) {
self::$instance = new self($rules, $message, $field);
}
return self::$instance;
}
protected function is($value, $rule, $data = [])
{
}
public static function __callStatic($method, $params)
{
var_dump($params);exit;
$class = self::make();
if (method_exists($class, $method)) {
return call_user_func_array([$class, $method], $params);
} else {
throw new \BadMethodCallException('method not exists:' . __CLASS__ . '->' . $method);
}
}
}
Test::is(555, 'email');
本地环境 php7.4.28
成功获取参数
array(2) { [0]=> int(555) [1]=> string(5) "email" }
生产环境 php7.3.0
获取参数失败
array(2) { }
个人结论
目前确认是 php7.3.0 的问题,如果有朋友知道什么原因,谢谢解答。
看了一下,确有相关问题,其是在 7.3.2 中被修复的。
相关链接