4
4
5
5
namespace Nyholm \Psr7 ;
6
6
7
+ use Psr \Http \Message \MessageInterface ;
7
8
use Psr \Http \Message \StreamInterface ;
8
9
9
10
/**
@@ -34,7 +35,10 @@ public function getProtocolVersion(): string
34
35
return $ this ->protocol ;
35
36
}
36
37
37
- public function withProtocolVersion ($ version ): self
38
+ /**
39
+ * @return static
40
+ */
41
+ public function withProtocolVersion ($ version ): MessageInterface
38
42
{
39
43
if (!\is_scalar ($ version )) {
40
44
throw new \InvalidArgumentException ('Protocol version must be a string ' );
@@ -81,7 +85,10 @@ public function getHeaderLine($header): string
81
85
return \implode (', ' , $ this ->getHeader ($ header ));
82
86
}
83
87
84
- public function withHeader ($ header , $ value ): self
88
+ /**
89
+ * @return static
90
+ */
91
+ public function withHeader ($ header , $ value ): MessageInterface
85
92
{
86
93
$ value = $ this ->validateAndTrimHeader ($ header , $ value );
87
94
$ normalized = \strtr ($ header , 'ABCDEFGHIJKLMNOPQRSTUVWXYZ ' , 'abcdefghijklmnopqrstuvwxyz ' );
@@ -96,7 +103,10 @@ public function withHeader($header, $value): self
96
103
return $ new ;
97
104
}
98
105
99
- public function withAddedHeader ($ header , $ value ): self
106
+ /**
107
+ * @return static
108
+ */
109
+ public function withAddedHeader ($ header , $ value ): MessageInterface
100
110
{
101
111
if (!\is_string ($ header ) || '' === $ header ) {
102
112
throw new \InvalidArgumentException ('Header name must be an RFC 7230 compatible string ' );
@@ -108,7 +118,10 @@ public function withAddedHeader($header, $value): self
108
118
return $ new ;
109
119
}
110
120
111
- public function withoutHeader ($ header ): self
121
+ /**
122
+ * @return static
123
+ */
124
+ public function withoutHeader ($ header ): MessageInterface
112
125
{
113
126
if (!\is_string ($ header )) {
114
127
throw new \InvalidArgumentException ('Header name must be an RFC 7230 compatible string ' );
@@ -135,7 +148,10 @@ public function getBody(): StreamInterface
135
148
return $ this ->stream ;
136
149
}
137
150
138
- public function withBody (StreamInterface $ body ): self
151
+ /**
152
+ * @return static
153
+ */
154
+ public function withBody (StreamInterface $ body ): MessageInterface
139
155
{
140
156
if ($ body === $ this ->stream ) {
141
157
return $ this ;
0 commit comments