Skip to content

Commit

Permalink
Make Parser + PendingReadError final, add explicit note about extensi…
Browse files Browse the repository at this point in the history
…on to Message
  • Loading branch information
kelunik committed May 25, 2017
1 parent 6bc8199 commit 21945b8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
8 changes: 5 additions & 3 deletions lib/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
* Creates a buffered message from an InputStream. The message can be consumed in chunks using the read() API or it may
* be buffered and accessed in its entirety by waiting for the promise to resolve.
*
* Other implementations may extend this class to add custom properties such as a `isBinary()` flag for WebSocket
* messages.
*
* Buffering Example:
*
* $stream = new Message($inputStream);
Expand Down Expand Up @@ -84,6 +87,7 @@ private function consume(): \Generator {
return $this->buffer;
}

/** @inheritdoc */
final public function read(): Promise {
if ($this->pendingRead) {
throw new PendingReadError;
Expand Down Expand Up @@ -114,9 +118,7 @@ final public function read(): Promise {
return $this->pendingRead->promise();
}

/**
* {@inheritdoc}
*/
/** @inheritdoc */
final public function onResolve(callable $onResolved) {
$this->buffering = true;

Expand Down
2 changes: 1 addition & 1 deletion lib/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Amp\Promise;
use Amp\Success;

class Parser implements OutputStream {
final class Parser implements OutputStream {
/** @var \Generator */
private $generator;

Expand Down
2 changes: 1 addition & 1 deletion lib/PendingReadError.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
* Thrown in case a second read operation is attempted while another read operation is still pending.
*/
class PendingReadError extends \Error {
final class PendingReadError extends \Error {
public function __construct(
string $message = "The previous read operation must complete before read can be called again",
int $code = 0,
Expand Down

0 comments on commit 21945b8

Please sign in to comment.