elastic / elasticsearch-php

Official PHP client for Elasticsearch.
https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/index.html
MIT License
35 stars 970 forks source link

Incorrect return typehint on IndicesNamespace::get v5.5.0 #1141

Closed avfletch closed 3 years ago

avfletch commented 3 years ago

Summary of problem or feature request

PHPStan (and presumably Psalm) detects incorrect return type for IndicesNamespace::get.

Please note, it's a docblock comment not a return typehint so I imagine this is low priority.

This is caused by -

IndicesNamespace.php::41

/**
     * $params['index'] = (list) A comma-separated list of indices to check (Required)
     *        ['feature'] = (list) A comma-separated list of features to return
     *        ['ignore_unavailable'] = (bool) Whether specified concrete indices should be ignored when unavailable (missing or closed)
     *        ['allow_no_indices']   = (bool) Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
     *        ['expand_wildcards']   = (enum) Whether to expand wildcard expression to concrete indices that are open, closed or both.
     *        ['local']   = (bool) Return local information, do not retrieve the state from master node (default: false)
     *
     * @param $params array Associative array of parameters
     *
     * @return bool
     */
    public function get($params)

This should be @return array the same as all the other methods except for exists.

I've checked the v5.x branch and it's correct on there so should be fixed by creating a new tagged version off that with nothing else to do.

Code snippet of problem

function demo(): array
{
  return $client->indices()->get([ 'index' => 'index' ]);
}

Then run PHPStan on that code and you'll get -

Function demo() should return array but returns bool.

System details

elasticsearch-php v5.5.0

Please note - I'm happy to fix this myself and submit a PR if you'd like me to but having never contributed to the project I wanted to raise the issue here to make sure it was desirable to do so, especially since the fix is probably just creating a new tag.

ezimuel commented 3 years ago

@avfletch I'm sorry but we are not supporting anymore v5. We are supporting 7.x and 6.8.x.