Help Center> Object Storage Service> PHP> FAQs> How Do I Resolve "Declaration of xxxx must be compatible with xxxx problem"?
Updated on 2024-01-08 GMT+08:00

How Do I Resolve "Declaration of xxxx must be compatible with xxxx problem"?

Such an error happens typically when versions are incompatible, given that dependencies for open-source software in the community are updated irregularly. The following gives an example error:

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

This error says that CheckoutStream::read($length) does not declare the int type. A possible reason is that psr/http-message has a newer version, the number of which can be obtained from composer.lock. GitHub also shows that psr/http-message has been upgraded from version 1.1 to 2.0, with the int type declared in 2.0. To resolve this error, you can downgrade psr/http-message to version 1.1.