<?php
/**
- * @copyright Copyright (C) 2021, Friendica
+ * @copyright Copyright (C) 2010-2022, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
* @param string $filename File to open
* @return $this
*/
- public function open(string $filename)
+ public function open(string $filename): ReversedFileReader
{
$this->fh = fopen($filename, 'r');
if (!$this->fh) {
/**
* Read $size bytes behind last position
*
+ * @param int $size
* @return string
*/
- private function _read($size)
+ private function _read(int $size): string
{
$this->pos -= $size;
fseek($this->fh, $this->pos);
* Read next line from end of file
* Return null if no lines are left to read
*
- * @return ?string
+ * @return string|null Depending on data being buffered
*/
private function _readline()
{
if ($this->pos == 0) {
return array_pop($buffer);
}
+ if (is_null($buffer)) {
+ return null;
+ }
if (count($buffer) > 1) {
return array_pop($buffer);
}
* @see Iterator::key()
* @return int
*/
- public function key()
+ public function key(): int
{
return $this->key;
}
* @see Iterator::current()
* @return string
*/
- public function current()
+ public function current(): string
{
return $this->value;
}
* @see Iterator::valid()
* @return bool
*/
- public function valid()
+ public function valid(): bool
{
return ! is_null($this->value);
}