美文网首页
PHP从7.4升级到8.2遇到的问题

PHP从7.4升级到8.2遇到的问题

作者: 洗耳恭听_kai | 来源:发表于2023-12-11 16:02 被阅读0次

1、preg_replace_callback(): Passing null to parameter #3 ($subject) of type array|string is deprecated

image.png

解决方法:

image.png image.png

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


image.png

改成:


image.png

2、

image.png

解决办法:

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

name 改成: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));
    }

相关文章

网友评论

      本文标题:PHP从7.4升级到8.2遇到的问题

      本文链接:https://www.haomeiwen.com/subject/gbdmgdtx.html