55use Bitrix \Main \ArgumentTypeException ;
66use Bitrix \Main \HttpResponse ;
77use GuzzleHttp \Psr7 \Utils ;
8+ use Psr \Http \Message \MessageInterface ;
89use Psr \Http \Message \ResponseInterface ;
910use Psr \Http \Message \StreamInterface ;
1011use Serializable ;
@@ -51,47 +52,47 @@ public function __construct(HttpResponse $response, ?string $httpVersion = null,
5152 /**
5253 * @inheritDoc
5354 */
54- public function getProtocolVersion ()
55+ public function getProtocolVersion () : string
5556 {
5657 return $ this ->httpVersion ;
5758 }
5859
5960 /**
6061 * @inheritDoc
6162 */
62- public function withProtocolVersion ($ version )
63+ public function withProtocolVersion ($ version ) : MessageInterface
6364 {
6465 return new static ($ this ->response , $ version , $ this ->body );
6566 }
6667
6768 /**
6869 * @inheritDoc
6970 */
70- public function getHeaders ()
71+ public function getHeaders () : array
7172 {
7273 return $ this ->response ->getHeaders ()->toArray ();
7374 }
7475
7576 /**
7677 * @inheritDoc
7778 */
78- public function hasHeader ($ name )
79+ public function hasHeader ($ name ) : bool
7980 {
8081 return !empty ($ this ->getHeader ($ name ));
8182 }
8283
8384 /**
8485 * @inheritDoc
8586 */
86- public function getHeader ($ name )
87+ public function getHeader ($ name ) : array
8788 {
8889 return $ this ->response ->getHeaders ()->get ($ name , true );
8990 }
9091
9192 /**
9293 * @inheritDoc
9394 */
94- public function getHeaderLine ($ name )
95+ public function getHeaderLine ($ name ) : string
9596 {
9697 $ value = $ this ->getHeader ($ name );
9798 if (empty ($ value )) {
@@ -104,7 +105,7 @@ public function getHeaderLine($name)
104105 /**
105106 * @inheritDoc
106107 */
107- public function withHeader ($ name , $ value )
108+ public function withHeader ($ name , $ value ) : MessageInterface
108109 {
109110 $ newResponse = clone $ this ->response ;
110111 $ newResponse ->getHeaders ()->set ($ name , $ value );
@@ -115,7 +116,7 @@ public function withHeader($name, $value)
115116 /**
116117 * @inheritDoc
117118 */
118- public function withAddedHeader ($ name , $ value )
119+ public function withAddedHeader ($ name , $ value ) : MessageInterface
119120 {
120121 if ($ this ->hasHeader ($ name )) {
121122 return $ this ;
@@ -127,7 +128,7 @@ public function withAddedHeader($name, $value)
127128 /**
128129 * @inheritDoc
129130 */
130- public function withoutHeader ($ name )
131+ public function withoutHeader ($ name ) : MessageInterface
131132 {
132133 if (!$ this ->hasHeader ($ name )) {
133134 return $ this ;
@@ -141,7 +142,7 @@ public function withoutHeader($name)
141142 /**
142143 * @inheritDoc
143144 */
144- public function getBody ()
145+ public function getBody () : StreamInterface
145146 {
146147 if (!$ this ->body ) {
147148 $ this ->body = Utils::streamFor ($ this ->response ->getContent ());
@@ -154,7 +155,7 @@ public function getBody()
154155 * @inheritDoc
155156 * @throws ArgumentTypeException
156157 */
157- public function withBody (StreamInterface $ body )
158+ public function withBody (StreamInterface $ body ) : MessageInterface
158159 {
159160 $ newResponse = clone $ this ->response ;
160161 $ newResponse ->setContent ($ body );
@@ -166,7 +167,7 @@ public function withBody(StreamInterface $body)
166167 /**
167168 * @inheritDoc
168169 */
169- public function getStatusCode ()
170+ public function getStatusCode () : int
170171 {
171172 preg_match ('/(\d+)\s+.*/ ' , $ this ->response ->getStatus (), $ match );
172173 return (int )($ match [1 ] ?? 200 );
@@ -175,7 +176,7 @@ public function getStatusCode()
175176 /**
176177 * @inheritDoc
177178 */
178- public function withStatus ($ code , $ reasonPhrase = '' )
179+ public function withStatus ($ code , $ reasonPhrase = '' ) : ResponseInterface
179180 {
180181 $ newResponse = clone $ this ->response ;
181182 $ newResponse ->getHeaders ()->set ('Status ' , implode (' ' , [$ code , $ reasonPhrase ]));
@@ -186,7 +187,7 @@ public function withStatus($code, $reasonPhrase = '')
186187 /**
187188 * @inheritDoc
188189 */
189- public function getReasonPhrase ()
190+ public function getReasonPhrase () : string
190191 {
191192 preg_match ('/\d+\s+(.*)/ ' , $ this ->response ->getStatus (), $ match );
192193 return $ match [1 ] ?? '' ;
0 commit comments