elasticsearch-php
elasticsearch-php copied to clipboard
Add return types to MessageResponseTrait to match upcoming PSR interface
I was getting several deprecations notices so I added the return types that will be added to the PSR interfaces we use.
For completeness here are the messages:
User Deprecated: Method "ArrayAccess::offsetGet()" might add "mixed" as a native return type declaration in the future. Do the same in implementation "Elastic\Elasticsearch\Response\Elasticsearch" now to avoid errors or add an explicit @return annotation to suppress this message.
User Deprecated: Method "Psr\Http\Message\MessageInterface::getProtocolVersion()" might add "string" as a native return type declaration in the future. Do the same in implementation "Elastic\Elasticsearch\Response\Elasticsearch" now to avoid errors or add an explicit @return annotation to suppress this message.
User Deprecated: Method "Psr\Http\Message\MessageInterface::withProtocolVersion()" might add "static" as a native return type declaration in the future. Do the same in implementation "Elastic\Elasticsearch\Response\Elasticsearch" now to avoid errors or add an explicit @return annotation to suppress this message.
User Deprecated: Method "Psr\Http\Message\MessageInterface::getHeaders()" might add "array" as a native return type declaration in the future. Do the same in implementation "Elastic\Elasticsearch\Response\Elasticsearch" now to avoid errors or add an explicit @return annotation to suppress this message.
User Deprecated: Method "Psr\Http\Message\MessageInterface::hasHeader()" might add "bool" as a native return type declaration in the future. Do the same in implementation "Elastic\Elasticsearch\Response\Elasticsearch" now to avoid errors or add an explicit @return annotation to suppress this message.
User Deprecated: Method "Psr\Http\Message\MessageInterface::getHeader()" might add "array" as a native return type declaration in the future. Do the same in implementation "Elastic\Elasticsearch\Response\Elasticsearch" now to avoid errors or add an explicit @return annotation to suppress this message.
User Deprecated: Method "Psr\Http\Message\MessageInterface::getHeaderLine()" might add "string" as a native return type declaration in the future. Do the same in implementation "Elastic\Elasticsearch\Response\Elasticsearch" now to avoid errors or add an explicit @return annotation to suppress this message.
User Deprecated: Method "Psr\Http\Message\MessageInterface::withHeader()" might add "static" as a native return type declaration in the future. Do the same in implementation "Elastic\Elasticsearch\Response\Elasticsearch" now to avoid errors or add an explicit @return annotation to suppress this message.
User Deprecated: Method "Psr\Http\Message\MessageInterface::withAddedHeader()" might add "static" as a native return type declaration in the future. Do the same in implementation "Elastic\Elasticsearch\Response\Elasticsearch" now to avoid errors or add an explicit @return annotation to suppress this message.
User Deprecated: Method "Psr\Http\Message\MessageInterface::withoutHeader()" might add "static" as a native return type declaration in the future. Do the same in implementation "Elastic\Elasticsearch\Response\Elasticsearch" now to avoid errors or add an explicit @return annotation to suppress this message.
User Deprecated: Method "Psr\Http\Message\MessageInterface::getBody()" might add "StreamInterface" as a native return type declaration in the future. Do the same in implementation "Elastic\Elasticsearch\Response\Elasticsearch" now to avoid errors or add an explicit @return annotation to suppress this message.
User Deprecated: Method "Psr\Http\Message\MessageInterface::withBody()" might add "static" as a native return type declaration in the future. Do the same in implementation "Elastic\Elasticsearch\Response\Elasticsearch" now to avoid errors or add an explicit @return annotation to suppress this message.
User Deprecated: Method "Psr\Http\Message\ResponseInterface::getStatusCode()" might add "int" as a native return type declaration in the future. Do the same in implementation "Elastic\Elasticsearch\Response\Elasticsearch" now to avoid errors or add an explicit @return annotation to suppress this message.
User Deprecated: Method "Psr\Http\Message\ResponseInterface::withStatus()" might add "static" as a native return type declaration in the future. Do the same in implementation "Elastic\Elasticsearch\Response\Elasticsearch" now to avoid errors or add an explicit @return annotation to suppress this message.
User Deprecated: Method "Psr\Http\Message\ResponseInterface::getReasonPhrase()" might add "string" as a native return type declaration in the future. Do the same in implementation "Elastic\Elasticsearch\Response\Elasticsearch" now to avoid errors or add an explicit @return annotation to suppress this message.
Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually?
So unfortunately static (https://www.php.net/manual/en/language.types.declarations.php#language.types.declarations.static) was added in PHP 8.0. Not sure how you want to proceed with this issue @ezimuel .
@hacfi which version of PHP and elasticsearch-php are you using? Thanks.
@ezimuel I'm using PHP 8.1.9 and elasticsearch-php 8.4.0. These notices come from Symfony (6.1.5).
Just rebased the the latest master and the issue persists:

This issue has existed since October 2022. Which version fixed it? It's a depression from PHP >8.1 / Symonfy > 6.1. ...
Sorry for the late reply. I fixed this issue with https://github.com/elastic/elasticsearch-php/commit/6bd60df64003de3414b84885d4ea075f3b9cd0ae. @hacfi and @mrichter1234 let me know if this solve your issue, thanks!
Thanks @ezimuel. It seems that the following passage has been forgotten. This continues to bring deprecated. Can you please fix it with the next version.