20
20
use Gitlab \HttpClient \Util \JsonArray ;
21
21
use Gitlab \HttpClient \Util \QueryStringBuilder ;
22
22
use Http \Message \MultipartStream \MultipartStreamBuilder ;
23
+ use Psr \Http \Message \ResponseInterface ;
23
24
use Psr \Http \Message \StreamInterface ;
24
25
use Symfony \Component \OptionsResolver \OptionsResolver ;
25
26
@@ -74,7 +75,7 @@ public function __construct(Client $client)
74
75
*
75
76
* @return \Psr\Http\Message\ResponseInterface
76
77
*/
77
- protected function getAsResponse (string $ uri , array $ params = [], array $ headers = [])
78
+ protected function getAsResponse (string $ uri , array $ params = [], array $ headers = []): ResponseInterface
78
79
{
79
80
if (null !== $ this ->perPage && !isset ($ params ['per_page ' ])) {
80
81
$ params ['per_page ' ] = $ this ->perPage ;
@@ -176,7 +177,7 @@ protected function delete(string $uri, array $params = [], array $headers = [])
176
177
*
177
178
* @return string
178
179
*/
179
- protected static function encodePath ($ uri )
180
+ protected static function encodePath ($ uri ): string
180
181
{
181
182
return \rawurlencode ((string ) $ uri );
182
183
}
@@ -187,7 +188,7 @@ protected static function encodePath($uri)
187
188
*
188
189
* @return string
189
190
*/
190
- protected function getProjectPath ($ id , string $ uri )
191
+ protected function getProjectPath ($ id , string $ uri ): string
191
192
{
192
193
return 'projects/ ' .self ::encodePath ($ id ).'/ ' .$ uri ;
193
194
}
@@ -197,18 +198,18 @@ protected function getProjectPath($id, string $uri)
197
198
*
198
199
* @return OptionsResolver
199
200
*/
200
- protected function createOptionsResolver ()
201
+ protected function createOptionsResolver (): OptionsResolver
201
202
{
202
203
$ resolver = new OptionsResolver ();
203
204
$ resolver ->setDefined ('page ' )
204
205
->setAllowedTypes ('page ' , 'int ' )
205
- ->setAllowedValues ('page ' , function ($ value ) {
206
+ ->setAllowedValues ('page ' , function ($ value ): bool {
206
207
return $ value > 0 ;
207
208
})
208
209
;
209
210
$ resolver ->setDefined ('per_page ' )
210
211
->setAllowedTypes ('per_page ' , 'int ' )
211
- ->setAllowedValues ('per_page ' , function ($ value ) {
212
+ ->setAllowedValues ('per_page ' , function ($ value ): bool {
212
213
return $ value > 0 && $ value <= 100 ;
213
214
})
214
215
;
@@ -224,7 +225,7 @@ protected function createOptionsResolver()
224
225
*
225
226
* @return string
226
227
*/
227
- private static function prepareUri (string $ uri , array $ query = [])
228
+ private static function prepareUri (string $ uri , array $ query = []): string
228
229
{
229
230
$ query = \array_filter ($ query , function ($ value ): bool {
230
231
return null !== $ value ;
@@ -241,7 +242,7 @@ private static function prepareUri(string $uri, array $query = [])
241
242
*
242
243
* @return MultipartStreamBuilder
243
244
*/
244
- private function createMultipartStreamBuilder (array $ params = [], array $ files = [])
245
+ private function createMultipartStreamBuilder (array $ params = [], array $ files = []): MultipartStreamBuilder
245
246
{
246
247
$ builder = new MultipartStreamBuilder ($ this ->client ->getStreamFactory ());
247
248
@@ -268,7 +269,7 @@ private function createMultipartStreamBuilder(array $params = [], array $files =
268
269
*
269
270
* @return StreamInterface
270
271
*/
271
- private static function prepareMultipartBody (MultipartStreamBuilder $ builder )
272
+ private static function prepareMultipartBody (MultipartStreamBuilder $ builder ): StreamInterface
272
273
{
273
274
return $ builder ->build ();
274
275
}
@@ -281,7 +282,7 @@ private static function prepareMultipartBody(MultipartStreamBuilder $builder)
281
282
*
282
283
* @return array<string,string>
283
284
*/
284
- private static function addMultipartContentType (array $ headers , MultipartStreamBuilder $ builder )
285
+ private static function addMultipartContentType (array $ headers , MultipartStreamBuilder $ builder ): array
285
286
{
286
287
$ contentType = \sprintf ('%s; boundary=%s ' , ResponseMediator::MULTIPART_CONTENT_TYPE , $ builder ->getBoundary ());
287
288
@@ -295,7 +296,7 @@ private static function addMultipartContentType(array $headers, MultipartStreamB
295
296
*
296
297
* @return string|null
297
298
*/
298
- private static function prepareJsonBody (array $ params )
299
+ private static function prepareJsonBody (array $ params ): ? string
299
300
{
300
301
$ params = \array_filter ($ params , function ($ value ): bool {
301
302
return null !== $ value ;
@@ -315,7 +316,7 @@ private static function prepareJsonBody(array $params)
315
316
*
316
317
* @return array<string,string>
317
318
*/
318
- private static function addJsonContentType (array $ headers )
319
+ private static function addJsonContentType (array $ headers ): array
319
320
{
320
321
return \array_merge ([ResponseMediator::CONTENT_TYPE_HEADER => ResponseMediator::JSON_CONTENT_TYPE ], $ headers );
321
322
}
@@ -365,7 +366,7 @@ private static function tryFopen(string $filename, string $mode)
365
366
*
366
367
* @return string
367
368
*/
368
- private static function guessFileContentType (string $ file )
369
+ private static function guessFileContentType (string $ file ): string
369
370
{
370
371
if (!\class_exists (\finfo::class, false )) {
371
372
return ResponseMediator::STREAM_CONTENT_TYPE ;
0 commit comments