有朋友碰到 PHP __callStatic() 拿不到参数的情况吗?

今天在使用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 的问题,如果有朋友知道什么原因,谢谢解答。

阅读 1.3k
1 个回答
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题