警告:array_keys()期望参数1为array, null给定


Warning: array_keys() expects parameter 1 to be array, null given

奇怪的解析器错误:

Notice: Undefined property: template::$param in 
    C:'xampp'htdocs'app'includes'classes'class.template.php on line 37
Warning: array_keys() expects parameter 1 to be array, null given in 
    C:'xampp'htdocs'app'includes'classes'class.template.php on line 37
Notice: Undefined property: template::$param in 
    C:'xampp'htdocs'app'includes'classes'class.template.php on line 37
Warning: array_values() expects parameter 1 to be array, null given in 
    C:'xampp'htdocs'app'includes'classes'class.template.php on line 37
代码:

public function newParam($trans, $value) {
    $this->param['{' . $trans . '}'] = $value;
}
public function getParam($content) {
    $content = str_replace(
        array_keys($this->param), 
        array_values($this->param), 
        $content
    );
    return $content;
}

初始化你的"param":

function __construct() {
  $this->param = array();
}

你也可以看到PHP文档

Creating/modifying with square bracket syntax
An existing array can be modified by explicitly setting values in it.
This is done by assigning values to the array, specifying the key in brackets. The key can also be omitted, resulting in an empty pair of brackets ([]).
$arr[key] = value;
$arr[] = value;
// key may be an integer or string
// value may be any value of any type

为laravel>= 5.5确保fideloper/proxy版本为4.0

"require": {
        "php": "^7.1.3",
        "**fideloper/proxy**": **"^4.0"**,