Issues (10)

php-src/Traits/TProtocol.php (1 issue)

1
<?php
2
3
namespace kalanis\RemoteRequestPsr\Traits;
4
5
6
use Psr\Http\Message\MessageInterface;
7
8
9
/**
10
 * Trait TProtocol
11
 * @package kalanis\RemoteRequestPsr\Traits
12
 * Note: Contrary the PSR requirements this class does not offer immutability
13
 * That's because you need to change request properties before you set them to RemoteRequest
14
 */
15
trait TProtocol
16
{
17
    protected string $protocol = '1.0';
18
19 1
    public function getProtocolVersion(): string
20
    {
21 1
        return $this->protocol;
22
    }
23
24 1
    public function withProtocolVersion(string $version): MessageInterface
25
    {
26 1
        if (preg_match('#(\d+)\.(\d+)#', $version)) {
27 1
            $this->protocol = $version;
28
        }
29 1
        return $this;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this returns the type kalanis\RemoteRequestPsr\Traits\TProtocol which is incompatible with the type-hinted return Psr\Http\Message\MessageInterface.
Loading history...
30
    }
31
}
32