Skip to content

Commit

Permalink
Add types
Browse files Browse the repository at this point in the history
  • Loading branch information
xepozz committed Jun 11, 2023
1 parent efc7916 commit 23c4bea
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions src/ServerSentEventsStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ public function __construct(
) {
}

public function __toString(): string
{
return '';
}

public function close(): void
{
$this->eof = true;
Expand All @@ -37,12 +32,12 @@ public function getSize()
return null;
}

public function tell()
public function tell(): int
{
// TODO: Implement tell() method.
return 0;
}

public function eof()
public function eof(): bool
{
return $this->eof;
}
Expand All @@ -52,12 +47,12 @@ public function isSeekable(): bool
return false;
}

public function seek($offset, $whence = SEEK_SET)
public function seek($offset, $whence = SEEK_SET): void
{
throw new \RuntimeException('Stream is not seekable');
}

public function rewind()
public function rewind(): void
{
throw new \RuntimeException('Stream is not seekable');
}
Expand All @@ -67,7 +62,7 @@ public function isWritable(): bool
return false;
}

public function write($string)
public function write($string): void
{
throw new \RuntimeException('Stream is not writable');
}
Expand All @@ -77,7 +72,10 @@ public function isReadable(): bool
return true;
}

public function read($length): string
/**
* TODO: support length reading
*/
public function read(int $length): string
{
$continue = ($this->stream)($this->buffer);

Expand All @@ -94,13 +92,18 @@ public function read($length): string
return $output;
}

public function getContents()
public function getContents(): string
{
// TODO: Implement getContents() method.
return $this->read(1024);
}

public function getMetadata($key = null): array
{
return [];
}

public function __toString(): string
{
return $this->getContents();
}
}

0 comments on commit 23c4bea

Please # to comment.