Skip to content
This repository was archived by the owner on Jan 30, 2020. It is now read-only.

Commit c25814d

Browse files
committed
Merge branch 'hotfix/125' into develop
Forward port #125
2 parents 4cb4192 + 46f531c commit c25814d

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

src/Client.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1240,20 +1240,20 @@ protected function prepareBody()
12401240
}
12411241

12421242
$body = '';
1243-
$totalFiles = 0;
1243+
$hasFiles = false;
12441244

12451245
if (! $this->getRequest()->getHeaders()->has('Content-Type')) {
1246-
$totalFiles = count($this->getRequest()->getFiles()->toArray());
1246+
$hasFiles = ! empty($this->getRequest()->getFiles()->toArray());
12471247
// If we have files to upload, force encType to multipart/form-data
1248-
if ($totalFiles > 0) {
1248+
if ($hasFiles) {
12491249
$this->setEncType(self::ENC_FORMDATA);
12501250
}
12511251
} else {
12521252
$this->setEncType($this->getHeader('Content-Type'));
12531253
}
12541254

12551255
// If we have POST parameters or files, encode and add them to the body
1256-
if (count($this->getRequest()->getPost()->toArray()) > 0 || $totalFiles > 0) {
1256+
if (! empty($this->getRequest()->getPost()->toArray()) || $hasFiles) {
12571257
if (stripos($this->getEncType(), self::ENC_FORMDATA) === 0) {
12581258
$boundary = '---ZENDHTTPCLIENT-' . md5(microtime());
12591259
$this->setEncType(self::ENC_FORMDATA, $boundary);

src/Request.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public static function fromString($string, $allowCustomMethods = true)
121121
$request->setVersion($matches['version']);
122122
}
123123

124-
if (count($lines) == 0) {
124+
if (empty($lines)) {
125125
return $request;
126126
}
127127

src/Response.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ public static function fromString($string)
202202
$response->setStatusCode($matches['status']);
203203
$response->setReasonPhrase((isset($matches['reason']) ? $matches['reason'] : ''));
204204

205-
if (count($lines) === 0) {
205+
if (empty($lines)) {
206206
return $response;
207207
}
208208

src/Response/Stream.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ public static function fromStream($responseString, $stream)
160160
$responseArray = explode("\n", $responseString);
161161
}
162162

163-
while (count($responseArray)) {
163+
while (! empty($responseArray)) {
164164
$nextLine = array_shift($responseArray);
165165
$headersString .= $nextLine . "\n";
166166
$nextLineTrimmed = trim($nextLine);
@@ -191,7 +191,7 @@ public static function fromStream($responseString, $stream)
191191
$response->setStream($stream);
192192
}
193193

194-
if (count($responseArray)) {
194+
if (! empty($responseArray)) {
195195
$response->content = implode("\n", $responseArray);
196196
}
197197

0 commit comments

Comments
 (0)