如何解决ForwardsCalls特征上的Illuminate /数据库语法错误

问题描述 投票:0回答:1

今天我正在更新我的网站时发生这种情况。实际上我甚至没有触摸这个文件,但由于某种原因它显示错误,我的网站无法加载。

这是问题所在

try {
        return $object->{$method}(...$parameters);
    } catch (Error | BadMethodCallException $e) { // "|" << this is the error
        $pattern = '~^Call to undefined method (?P<class>[^:]+)::(?P<method>[^\(]+)\(\)$~';

        if (! preg_match($pattern, $e->getMessage(), $matches)) {
            throw $e;
        }

        if ($matches['class'] != get_class($object) ||
            $matches['method'] != $method) {
            throw $e;
        }

        static::throwBadMethodCallException($method);
    }

我试图搜索捕获两个异常中的一个,但没有。我该怎么解决这个问题。我甚至不知道特质。谢谢你

php slim
1个回答
1
投票

来自exceptions documentation

在PHP 7.1及更高版本中,catch块可以使用管道(|)字符指定多个异常。

您正在使用较新版本的PHP但在旧版本上部署的计算机上进行开发。你真的应该考虑在两台机器上使用完全相同的PHP版本,以避免向后兼容性问题。

要解决您的问题,如果您的托管公司提供此类功能,您可以选择较新版本的PHP,或者将您正在使用的库降级为与主机PHP版本兼容的版本。我不推荐第二种方法,降级包以处理过时的依赖关系不是一个好主意。

© www.soinside.com 2019 - 2024. All rights reserved.