对象存储服务 OBS-如何解决 Declaration of xxxx must be compatible with xxxx?

时间:2024-01-19 14:11:31

如何解决 Declaration of xxxx must be compatible with xxxx?

如果遇到这种报错,基本上都是版本不兼容导致的,因为社区开源软件依赖会不定期更新。比如遇到以下报错:

Declaration of Obs\Internal\Common\CheckoutStream::read($length) must be compatible with Psr\Http\Message\StreamInterface::read(int $length)

从报错得知,CheckoutStream::read($length) 缺少int类型声明,很大可能就是psr/http-message版本太高(可以从composer.lock找到准确的版本号),另外查看Github社区发现psr/http-message 1.1版本升级到2.0 增加了类型声明,最后降低psr/http-message 版本为1.1解决问题。

support.huaweicloud.com/sdk-php-devg-obs/obs_28_1713.html