slimphp / Slim

Slim is a PHP micro framework that helps you quickly write simple yet powerful web applications and APIs.
http://slimframework.com
MIT License
11.98k stars 1.95k forks source link

PHPDoc of Slim\Http\Request::getParams it's wrong #2890

Closed sdecandelario closed 4 years ago

sdecandelario commented 4 years ago

Hello, In my project we use PHPStan for the static analysis, and throw me an error from the method getParams from \Slim\Http\Request because say the method can return null or array.

But i reviewd the two returns of the method and in both only return an array, that are or $onlyParams or $params, is the PHPDoc returnwrong?

odan commented 4 years ago

getParams from \Slim\Http\Request

In the latest version of slim/http the signature of ServerRequest::getParams looks like this:

/**
 * Fetch associative array of body and query string parameters.
 *
 * Note: This method is not part of the PSR-7 standard.
 *
 * @return mixed[]
*/
public function getParams(): array

But I could not find a Request::getParams method in slim/http.

A Phpstan scan didn't give me any errors.

Do you use Slim 3 or Slim 4?

sdecandelario commented 4 years ago

Sorry, I forgot to put the version we are using. We are in the version 3.11.0 for the moment

Here is the line in 3.11.0 and 3.12.3

3.11.0 https://github.com/slimphp/Slim/blob/3.11.0/Slim/Http/Request.php#L1207 3.12.3 https://github.com/slimphp/Slim/blob/3.12.3/Slim/Http/Request.php#L1189

l0gicgate commented 4 years ago

That's actually an error. We should fix that, it can only return an array.