Skip to content

Commit f8f029c

Browse files
authored
Merge pull request #286 from seregazhuk/small-code-improvements
Small code improvements
2 parents b75608e + ceba730 commit f8f029c

File tree

6 files changed

+14
-13
lines changed

6 files changed

+14
-13
lines changed

src/Io/ChunkedDecoder.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,12 @@ public function close()
7979
public function handleEnd()
8080
{
8181
if (!$this->closed) {
82-
$this->handleError(new \Exception('Unexpected end event'));
82+
$this->handleError(new Exception('Unexpected end event'));
8383
}
8484
}
8585

8686
/** @internal */
87-
public function handleError(\Exception $e)
87+
public function handleError(Exception $e)
8888
{
8989
$this->emit('error', array($e));
9090
$this->close();
@@ -102,7 +102,7 @@ public function handleData($data)
102102
if ($positionCrlf === false) {
103103
// Header shouldn't be bigger than 1024 bytes
104104
if (isset($this->buffer[static::MAX_CHUNK_HEADER_SIZE])) {
105-
$this->handleError(new \Exception('Chunk header size inclusive extension bigger than' . static::MAX_CHUNK_HEADER_SIZE. ' bytes'));
105+
$this->handleError(new Exception('Chunk header size inclusive extension bigger than' . static::MAX_CHUNK_HEADER_SIZE. ' bytes'));
106106
}
107107
return;
108108
}
@@ -124,7 +124,7 @@ public function handleData($data)
124124

125125
$this->chunkSize = hexdec($hexValue);
126126
if (dechex($this->chunkSize) !== $hexValue) {
127-
$this->handleError(new \Exception($hexValue . ' is not a valid hexadecimal number'));
127+
$this->handleError(new Exception($hexValue . ' is not a valid hexadecimal number'));
128128
return;
129129
}
130130

@@ -159,7 +159,7 @@ public function handleData($data)
159159

160160
if ($positionCrlf !== 0 && $this->chunkSize === $this->transferredSize && strlen($this->buffer) > 2) {
161161
// the first 2 characters are not CLRF, send error event
162-
$this->handleError(new \Exception('Chunk does not end with a CLRF'));
162+
$this->handleError(new Exception('Chunk does not end with a CLRF'));
163163
return;
164164
}
165165

src/Io/CloseProtectionStream.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* */
1818
class CloseProtectionStream extends EventEmitter implements ReadableStreamInterface
1919
{
20-
private $connection;
20+
private $input;
2121
private $closed = false;
2222

2323
/**

src/Io/LengthLimitedStream.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ class LengthLimitedStream extends EventEmitter implements ReadableStreamInterfac
1919
{
2020
private $stream;
2121
private $closed = false;
22-
private $encoder;
2322
private $transferredLength = 0;
2423
private $maxLength;
2524

src/Io/MultipartParser.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ private function parseUploadedFile($filename, $contentType, $contents)
190190
}
191191

192192
return new UploadedFile(
193-
Psr7\stream_for(''),
193+
Psr7\stream_for(),
194194
$size,
195195
UPLOAD_ERR_NO_FILE,
196196
$filename,
@@ -206,7 +206,7 @@ private function parseUploadedFile($filename, $contentType, $contents)
206206
// file exceeds "upload_max_filesize" ini setting
207207
if ($size > $this->uploadMaxFilesize) {
208208
return new UploadedFile(
209-
Psr7\stream_for(''),
209+
Psr7\stream_for(),
210210
$size,
211211
UPLOAD_ERR_INI_SIZE,
212212
$filename,
@@ -217,7 +217,7 @@ private function parseUploadedFile($filename, $contentType, $contents)
217217
// file exceeds MAX_FILE_SIZE value
218218
if ($this->maxFileSize !== null && $size > $this->maxFileSize) {
219219
return new UploadedFile(
220-
Psr7\stream_for(''),
220+
Psr7\stream_for(),
221221
$size,
222222
UPLOAD_ERR_FORM_SIZE,
223223
$filename,

src/Io/ServerRequest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
namespace React\Http\Io;
44

55
use Psr\Http\Message\ServerRequestInterface;
6+
use Psr\Http\Message\StreamInterface;
7+
use Psr\Http\Message\UriInterface;
68
use RingCentral\Psr7\Request;
79

810
/**
@@ -37,7 +39,7 @@ class ServerRequest extends Request implements ServerRequestInterface
3739
* @param string $protocolVersion HTTP protocol version.
3840
* @param array server-side parameters
3941
*
40-
* @throws InvalidArgumentException for an invalid URI
42+
* @throws \InvalidArgumentException for an invalid URI
4143
*/
4244
public function __construct(
4345
$method,

src/StreamingServer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ public function handleRequest(ConnectionInterface $conn, ServerRequestInterface
214214
$string = $request->getHeaderLine('Content-Length');
215215

216216
$contentLength = (int)$string;
217-
if ((string)$contentLength !== (string)$string) {
217+
if ((string)$contentLength !== $string) {
218218
// Content-Length value is not an integer or not a single integer
219219
$this->emit('error', array(new \InvalidArgumentException('The value of `Content-Length` is not valid')));
220220
return $this->writeError($conn, 400, $request);
@@ -355,7 +355,7 @@ public function handleResponse(ConnectionInterface $connection, ServerRequestInt
355355
// response to HEAD and 1xx, 204 and 304 responses MUST NOT include a body
356356
// exclude status 101 (Switching Protocols) here for Upgrade request handling below
357357
if ($request->getMethod() === 'HEAD' || $code === 100 || ($code > 101 && $code < 200) || $code === 204 || $code === 304) {
358-
$response = $response->withBody(Psr7Implementation\stream_for(''));
358+
$response = $response->withBody(Psr7Implementation\stream_for());
359359
}
360360

361361
// 101 (Switching Protocols) response uses Connection: upgrade header

0 commit comments

Comments
 (0)