PHP从7.4升级到8.2遇到的问题
2023-12-11 本文已影响0人
洗耳恭听_kai
1、preg_replace_callback(): Passing null to parameter #3 ($subject) of type array|string is deprecated

解决方法:


找到报错的位置:\thinkphp\library\think\Loader.php

改成:

2、

解决办法:
model中引入的
use think\model;
改成
use think\console\command\make\Model;
3、类型错误: preg_match(): Argument #2 ($subject) must be of type string, array given
解决办法:
找到文件位置:\thinkphp\library\think\console\Command.php 466
this->diy_to_string($name)
/**
* 验证指令名称
* @param string $name
* @throws \InvalidArgumentException
*/
private function validateName($name)
{
if (!preg_match('/^[^\:]++(\:[^\:]++)*$/', $this->diy_to_string($name))) {
throw new \InvalidArgumentException(sprintf('Command name "%s" is invalid.', $name));
}
}
function diy_to_string($variable)
{
return is_float($variable)?(string)$variable:(is_resource($variable)?"'resource of type'":var_export($variable, true));
}