diff options
author | Aryeh Gregor <ayg@aryeh.name> | 2022-04-25 22:05:56 +0300 |
---|---|---|
committer | Kevin Israel <pleasestand@live.com> | 2022-06-13 04:42:20 -0400 |
commit | c43521226011bd10381c9077b7c3ee14e4b21e89 (patch) | |
tree | 48600c15172ac9731c765bbda2841fe7383a009f /includes/libs/filebackend | |
parent | 89518d5024fab41fa6a153e6539ae0a6597d249d (diff) | |
download | mediawikicore-c43521226011bd10381c9077b7c3ee14e4b21e89.tar.gz mediawikicore-c43521226011bd10381c9077b7c3ee14e4b21e89.zip |
Get rid of warnings on PHP 8.1
This is mostly about adding return types to methods that implement PHP
interfaces, and not passing null to core functions that want a string.
After this patch, and an update to return types in RemexHtml,
tests/phpunit/integration/ has no more errors than in PHP 8.0.
Bug: T289879
Bug: T289926
Change-Id: Ia424f5cc897070f4188ae126b5bf6a1f552db0e1
Diffstat (limited to 'includes/libs/filebackend')
5 files changed, 12 insertions, 9 deletions
diff --git a/includes/libs/filebackend/fileiteration/FSFileBackendList.php b/includes/libs/filebackend/fileiteration/FSFileBackendList.php index 0783cc646ecd..047aa1dfeb35 100644 --- a/includes/libs/filebackend/fileiteration/FSFileBackendList.php +++ b/includes/libs/filebackend/fileiteration/FSFileBackendList.php @@ -89,7 +89,7 @@ abstract class FSFileBackendList implements Iterator { * @see Iterator::key() * @return int */ - public function key() { + public function key(): int { return $this->pos; } @@ -97,6 +97,7 @@ abstract class FSFileBackendList implements Iterator { * @see Iterator::current() * @return string|false */ + #[\ReturnTypeWillChange] public function current() { return $this->getRelPath( $this->iter->current()->getPathname() ); } @@ -105,7 +106,7 @@ abstract class FSFileBackendList implements Iterator { * @see Iterator::next() * @throws FileBackendError */ - public function next() { + public function next(): void { try { $this->iter->next(); $this->filterViaNext(); @@ -121,7 +122,7 @@ abstract class FSFileBackendList implements Iterator { * @see Iterator::rewind() * @throws FileBackendError */ - public function rewind() { + public function rewind(): void { $this->pos = 0; try { $this->iter->rewind(); @@ -137,7 +138,7 @@ abstract class FSFileBackendList implements Iterator { * @see Iterator::valid() * @return bool */ - public function valid() { + public function valid(): bool { return $this->iter && $this->iter->valid(); } diff --git a/includes/libs/filebackend/fileiteration/FileBackendStoreShardListIterator.php b/includes/libs/filebackend/fileiteration/FileBackendStoreShardListIterator.php index 5f6b76242645..9dc7cab4c6f9 100644 --- a/includes/libs/filebackend/fileiteration/FileBackendStoreShardListIterator.php +++ b/includes/libs/filebackend/fileiteration/FileBackendStoreShardListIterator.php @@ -79,7 +79,7 @@ abstract class FileBackendStoreShardListIterator extends FilterIterator { } } - public function rewind() { + public function rewind(): void { parent::rewind(); $this->multiShardPaths = []; } diff --git a/includes/libs/filebackend/fileiteration/SwiftFileBackendDirList.php b/includes/libs/filebackend/fileiteration/SwiftFileBackendDirList.php index b0b784d389c2..ca6f3d88bb0c 100644 --- a/includes/libs/filebackend/fileiteration/SwiftFileBackendDirList.php +++ b/includes/libs/filebackend/fileiteration/SwiftFileBackendDirList.php @@ -30,6 +30,7 @@ class SwiftFileBackendDirList extends SwiftFileBackendList { * @see Iterator::current() * @return string|bool String (relative path) or false */ + #[\ReturnTypeWillChange] public function current() { return substr( current( $this->bufferIter ), $this->suffixStart, -1 ); } diff --git a/includes/libs/filebackend/fileiteration/SwiftFileBackendFileList.php b/includes/libs/filebackend/fileiteration/SwiftFileBackendFileList.php index 045b8f878cd0..106193d710e0 100644 --- a/includes/libs/filebackend/fileiteration/SwiftFileBackendFileList.php +++ b/includes/libs/filebackend/fileiteration/SwiftFileBackendFileList.php @@ -30,6 +30,7 @@ class SwiftFileBackendFileList extends SwiftFileBackendList { * @see Iterator::current() * @return string|bool String (relative path) or false */ + #[\ReturnTypeWillChange] public function current() { list( $path, $stat ) = current( $this->bufferIter ); $relPath = substr( $path, $this->suffixStart ); diff --git a/includes/libs/filebackend/fileiteration/SwiftFileBackendList.php b/includes/libs/filebackend/fileiteration/SwiftFileBackendList.php index 45f3f4cd6f6c..a603900d65b6 100644 --- a/includes/libs/filebackend/fileiteration/SwiftFileBackendList.php +++ b/includes/libs/filebackend/fileiteration/SwiftFileBackendList.php @@ -81,14 +81,14 @@ abstract class SwiftFileBackendList implements Iterator { * @see Iterator::key() * @return int */ - public function key() { + public function key(): int { return $this->pos; } /** * @inheritDoc */ - public function next() { + public function next(): void { // Advance to the next file in the page next( $this->bufferIter ); ++$this->pos; @@ -104,7 +104,7 @@ abstract class SwiftFileBackendList implements Iterator { /** * @inheritDoc */ - public function rewind() { + public function rewind(): void { $this->pos = 0; $this->bufferAfter = null; $this->bufferIter = $this->pageFromList( @@ -117,7 +117,7 @@ abstract class SwiftFileBackendList implements Iterator { * @see Iterator::valid() * @return bool */ - public function valid() { + public function valid(): bool { if ( $this->bufferIter === null ) { return false; // some failure? } else { |