kbsali / php-redmine-api

A simple PHP Redmine API client, Object Oriented

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issue with http methods in lowercase

npotier opened this issue · comments

Hi, first of all thank you for your lib.

I'm having issues using this lib in a symfony project, and after digging a little I think that there may be a problem using lowercase in http methods such as get or post.

Here is my example :

// ...
use Nyholm\Psr7\Factory\Psr17Factory;
use Psr\Http\Client\ClientInterface;

// ...
public function __construct(ClientInterface $client)
{
        $psr17Factory = new Psr17Factory();

        // Instanciation of the RedmineClient
        $this->redmineClient = new \Redmine\Client\Psr18Client(
            $client,
            $psr17Factory,
            $psr17Factory,
            $redmineUrl,
            $redmineToken
        );
}
// ...
$users = $this->redmineClient->getApi('user')->all(['limit' => 100]);
// ...

This code is generating the current exception :

Invalid HTTP method "get", only uppercase letters are accepted.

From what I understand, the class Psr18Client generates HTTP calls with the methods requestGet(), requestPut(), etc. Unfortunatelly, this class is final so I can not extend it to overwrite these methods and put uppercase verbs in it.

Lowercase methods seems to be unsupported by the Symfony HTTP Client : https://github.com/symfony/http-client/blob/ef85ca5fa7a4f9c57592fab49faeccdf22b13136/HttpClientTrait.php#L48

Is there any chance that we can update the Psr18Client class and put the verbs in uppercase ? I'll be happy to submit a PR on it.

Nicolas.

Hi @npotier ,

well spotted! We'd be more than happy to get a PR for fixing this! 👍
thanks!

Thanks @kbsali I've submitted the PR 😉

I just released v1.8.1
Thank you for your contribution.