44
55namespace Nyholm \Psr7 ;
66
7+ use Psr \Http \Message \MessageInterface ;
78use Psr \Http \Message \StreamInterface ;
89
910/**
@@ -34,7 +35,10 @@ public function getProtocolVersion(): string
3435 return $ this ->protocol ;
3536 }
3637
37- public function withProtocolVersion ($ version ): self
38+ /**
39+ * @return static
40+ */
41+ public function withProtocolVersion ($ version ): MessageInterface
3842 {
3943 if (!\is_scalar ($ version )) {
4044 throw new \InvalidArgumentException ('Protocol version must be a string ' );
@@ -81,7 +85,10 @@ public function getHeaderLine($header): string
8185 return \implode (', ' , $ this ->getHeader ($ header ));
8286 }
8387
84- public function withHeader ($ header , $ value ): self
88+ /**
89+ * @return static
90+ */
91+ public function withHeader ($ header , $ value ): MessageInterface
8592 {
8693 $ value = $ this ->validateAndTrimHeader ($ header , $ value );
8794 $ normalized = \strtr ($ header , 'ABCDEFGHIJKLMNOPQRSTUVWXYZ ' , 'abcdefghijklmnopqrstuvwxyz ' );
@@ -96,7 +103,10 @@ public function withHeader($header, $value): self
96103 return $ new ;
97104 }
98105
99- public function withAddedHeader ($ header , $ value ): self
106+ /**
107+ * @return static
108+ */
109+ public function withAddedHeader ($ header , $ value ): MessageInterface
100110 {
101111 if (!\is_string ($ header ) || '' === $ header ) {
102112 throw new \InvalidArgumentException ('Header name must be an RFC 7230 compatible string ' );
@@ -108,7 +118,10 @@ public function withAddedHeader($header, $value): self
108118 return $ new ;
109119 }
110120
111- public function withoutHeader ($ header ): self
121+ /**
122+ * @return static
123+ */
124+ public function withoutHeader ($ header ): MessageInterface
112125 {
113126 if (!\is_string ($ header )) {
114127 throw new \InvalidArgumentException ('Header name must be an RFC 7230 compatible string ' );
@@ -135,7 +148,10 @@ public function getBody(): StreamInterface
135148 return $ this ->stream ;
136149 }
137150
138- public function withBody (StreamInterface $ body ): self
151+ /**
152+ * @return static
153+ */
154+ public function withBody (StreamInterface $ body ): MessageInterface
139155 {
140156 if ($ body === $ this ->stream ) {
141157 return $ this ;
0 commit comments