Skip to content

Commit ff07bfa

Browse files
authored
Merge pull request #35 from peter279k/issue_#34
Resolves issue #34
2 parents 30455a4 + 65a5fa4 commit ff07bfa

20 files changed

+113
-125
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ before_script:
3333
- composer install --prefer-dist --no-interaction -o
3434

3535
script:
36-
- ./vendor/bin/simple-phpunit -v --coverage-clover=coverage.clover
36+
- XDEBUG_MODE=coverage ./vendor/bin/simple-phpunit -v --coverage-clover=coverage.clover
3737
- if [ "$CS_FIXER" = "run" ]; then php vendor/bin/php-cs-fixer fix --verbose --dry-run ; fi;
3838

3939
after_script:

lib/Imgur/Api/Album.php

-3
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ public function favoriteAlbum($albumId)
122122
* (Not available for anonymous albums.).
123123
*
124124
* @param string $albumId
125-
* @param array $imageIds
126125
*
127126
* @see https://api.imgur.com/endpoints/album#album-set-to
128127
*
@@ -138,7 +137,6 @@ public function setAlbumImages($albumId, array $imageIds)
138137
* (Not available for anonymous albums. Adding images to an anonymous album is only available during image uploading.).
139138
*
140139
* @param string $albumId
141-
* @param array $imageIds
142140
*
143141
* @see https://api.imgur.com/endpoints/album#album-add-to
144142
*
@@ -154,7 +152,6 @@ public function addImages($albumId, array $imageIds)
154152
* For anonymous albums, $deletehashOrAlbumId should be the deletehash that is returned at creation.
155153
*
156154
* @param string $deletehashOrAlbumId
157-
* @param array $imageIds
158155
*
159156
* @see https://api.imgur.com/endpoints/album#album-remove-from
160157
*

lib/Imgur/Api/CustomGallery.php

-4
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,6 @@ public function image($imageId)
6464
/**
6565
* Add tags to a user's custom gallery.
6666
*
67-
* @param array $tags
68-
*
6967
* @see https://api.imgur.com/endpoints/custom_gallery#custom-gallery-add
7068
*
7169
* @return bool
@@ -78,8 +76,6 @@ public function addTags(array $tags)
7876
/**
7977
* Remove tags from a custom gallery.
8078
*
81-
* @param array $tags
82-
*
8379
* @see https://api.imgur.com/endpoints/custom_gallery#custom-gallery-remove
8480
*
8581
* @return bool

lib/Imgur/Api/Image.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function upload($data)
4949
}
5050

5151
if ('file' === $data['type']) {
52-
$data['image'] = '@' . $data['image'];
52+
$data['image'] = fopen($data['image'], 'r');
5353
}
5454

5555
return $this->post('image', $data);

lib/Imgur/Auth/OAuth2.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,8 @@ class OAuth2 implements AuthInterface
6262
/**
6363
* Instantiates the OAuth2 class, but does not trigger the authentication process.
6464
*
65-
* @param HttpClientInterface $httpClient
66-
* @param string $clientId
67-
* @param string $clientSecret
65+
* @param string $clientId
66+
* @param string $clientSecret
6867
*/
6968
public function __construct(HttpClientInterface $httpClient, $clientId, $clientSecret)
7069
{

lib/Imgur/Client.php

-3
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,6 @@ public function getHttpClient()
8181
return $this->httpClient;
8282
}
8383

84-
/**
85-
* @param HttpClientInterface $httpClient
86-
*/
8784
public function setHttpClient(HttpClientInterface $httpClient)
8885
{
8986
$this->httpClient = $httpClient;

lib/Imgur/HttpClient/HttpClient.php

+14-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ class HttpClient implements HttpClientInterface
3636
protected $stack;
3737

3838
/**
39-
* @param array $options
4039
* @param ClientInterface $client
4140
*/
4241
public function __construct(array $options = [], ClientInterface $client = null)
@@ -108,7 +107,20 @@ public function performRequest($url, $parameters, $httpMethod = 'GET')
108107
}
109108

110109
if ('POST' === $httpMethod || 'PUT' === $httpMethod || 'DELETE' === $httpMethod) {
111-
$options['form_params'] = $parameters;
110+
if ('POST' === $httpMethod && isset($parameters['type']) && 'file' === $parameters['type']) {
111+
$options['multipart'] = [
112+
[
113+
'name' => 'type',
114+
'contents' => $parameters['type'],
115+
],
116+
[
117+
'name' => 'image',
118+
'contents' => $parameters['image'],
119+
],
120+
];
121+
} else {
122+
$options['form_params'] = $parameters;
123+
}
112124
}
113125

114126
// will throw an Imgur\Exception\ExceptionInterface if sth goes wrong

lib/Imgur/Middleware/AuthMiddleware.php

-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ public function __construct($token, $clientId)
2323

2424
/**
2525
* Add Authorization header to the request.
26-
*
27-
* @param RequestInterface $request
2826
*/
2927
public function addAuthHeader(RequestInterface $request)
3028
{

lib/Imgur/Middleware/ErrorMiddleware.php

-11
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@ public function __construct(callable $nextHandler)
2121
}
2222

2323
/**
24-
* @param RequestInterface $request
25-
* @param array $options
26-
*
2724
* @return PromiseInterface
2825
*/
2926
public function __invoke(RequestInterface $request, array $options)
@@ -50,8 +47,6 @@ public static function error()
5047

5148
/**
5249
* Check for an error.
53-
*
54-
* @param ResponseInterface $response
5550
*/
5651
public function checkError(ResponseInterface $response)
5752
{
@@ -96,8 +91,6 @@ public function checkError(ResponseInterface $response)
9691

9792
/**
9893
* Check if user hit limit.
99-
*
100-
* @param ResponseInterface $response
10194
*/
10295
private function checkUserRateLimit(ResponseInterface $response)
10396
{
@@ -111,8 +104,6 @@ private function checkUserRateLimit(ResponseInterface $response)
111104

112105
/**
113106
* Check if client hit limit.
114-
*
115-
* @param ResponseInterface $response
116107
*/
117108
private function checkClientRateLimit(ResponseInterface $response)
118109
{
@@ -129,8 +120,6 @@ private function checkClientRateLimit(ResponseInterface $response)
129120

130121
/**
131122
* Check if client hit post limit.
132-
*
133-
* @param ResponseInterface $response
134123
*/
135124
private function checkPostRateLimit(ResponseInterface $response)
136125
{

0 commit comments

Comments
 (0)