elasticsearch-php icon indicating copy to clipboard operation
elasticsearch-php copied to clipboard

Add return types to MessageResponseTrait to match upcoming PSR interface

Open hacfi opened this issue 3 years ago • 5 comments

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.

hacfi avatar Sep 10 '22 06:09 hacfi

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?

elasticmachine avatar Sep 10 '22 06:09 elasticmachine

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 avatar Sep 10 '22 06:09 hacfi

@hacfi which version of PHP and elasticsearch-php are you using? Thanks.

ezimuel avatar Sep 29 '22 08:09 ezimuel

@ezimuel I'm using PHP 8.1.9 and elasticsearch-php 8.4.0. These notices come from Symfony (6.1.5).

hacfi avatar Sep 30 '22 12:09 hacfi

Just rebased the the latest master and the issue persists: image

hacfi avatar Oct 01 '22 10:10 hacfi

This issue has existed since October 2022. Which version fixed it? It's a depression from PHP >8.1 / Symonfy > 6.1. ...

mrichter1234 avatar Apr 18 '23 17:04 mrichter1234

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!

ezimuel avatar May 23 '23 09:05 ezimuel

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.

image image

mrichter1234 avatar May 30 '23 09:05 mrichter1234