diff options
31 files changed, 100 insertions, 91 deletions
diff --git a/includes/CommentFormatter/RowCommentIterator.php b/includes/CommentFormatter/RowCommentIterator.php index 498f2ea36424..4455b7378980 100644 --- a/includes/CommentFormatter/RowCommentIterator.php +++ b/includes/CommentFormatter/RowCommentIterator.php @@ -98,7 +98,7 @@ class RowCommentIterator extends IteratorIterator { return $this; } - public function key() { + public function key(): string { if ( $this->indexField ) { return parent::current()->{$this->indexField}; } else { @@ -106,7 +106,7 @@ class RowCommentIterator extends IteratorIterator { } } - public function current() { + public function current(): CommentItem { if ( $this->commentKey === null ) { throw new \RuntimeException( __METHOD__ . ': commentKey must be specified' ); } diff --git a/includes/CommentFormatter/StringCommentIterator.php b/includes/CommentFormatter/StringCommentIterator.php index 540c6b109b18..f9dba4e88d8d 100644 --- a/includes/CommentFormatter/StringCommentIterator.php +++ b/includes/CommentFormatter/StringCommentIterator.php @@ -19,7 +19,7 @@ class StringCommentIterator extends ArrayIterator { parent::__construct( $strings ); } - public function current() { + public function current(): CommentItem { return new CommentItem( parent::current() ); } } diff --git a/includes/EditPage.php b/includes/EditPage.php index d1388146a592..4886922476c9 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -1209,11 +1209,11 @@ class EditPage implements IEditObject { } } $this->save = !$this->preview && !$this->diff; - if ( !preg_match( '/^\d{14}$/', $this->edittime ) ) { + if ( !$this->edittime || !preg_match( '/^\d{14}$/', $this->edittime ) ) { $this->edittime = null; } - if ( !preg_match( '/^\d{14}$/', $this->starttime ) ) { + if ( !$this->starttime || !preg_match( '/^\d{14}$/', $this->starttime ) ) { $this->starttime = null; } diff --git a/includes/TitleArrayFromResult.php b/includes/TitleArrayFromResult.php index e02a592c89cd..9b2a91092c32 100644 --- a/includes/TitleArrayFromResult.php +++ b/includes/TitleArrayFromResult.php @@ -67,7 +67,7 @@ class TitleArrayFromResult extends TitleArray implements Countable { /** * @return int */ - public function count() { + public function count(): int { return $this->res->numRows(); } @@ -79,13 +79,13 @@ class TitleArrayFromResult extends TitleArray implements Countable { return $this->key; } - public function next() { + public function next(): void { $row = $this->res->fetchObject(); $this->setCurrent( $row ); $this->key++; } - public function rewind() { + public function rewind(): void { $this->res->rewind(); $this->key = 0; $this->setCurrent( $this->res->current() ); @@ -94,7 +94,7 @@ class TitleArrayFromResult extends TitleArray implements Countable { /** * @return bool */ - public function valid() { + public function valid(): bool { return $this->current !== false; } } diff --git a/includes/actions/McrUndoAction.php b/includes/actions/McrUndoAction.php index f39c31b573c8..0dc12c63c864 100644 --- a/includes/actions/McrUndoAction.php +++ b/includes/actions/McrUndoAction.php @@ -386,7 +386,7 @@ class McrUndoAction extends FormAction { $this->getContext(), $slot->getContent(), $status, - trim( $this->getRequest()->getVal( 'wpSummary' ) ), + trim( $this->getRequest()->getVal( 'wpSummary' ) ?? '' ), $this->getUser(), false ); @@ -426,7 +426,8 @@ class McrUndoAction extends FormAction { } $updater->saveRevision( - CommentStoreComment::newUnsavedComment( trim( $this->getRequest()->getVal( 'wpSummary' ) ) ), + CommentStoreComment::newUnsavedComment( + trim( $this->getRequest()->getVal( 'wpSummary' ) ?? '' ) ), EDIT_AUTOSUMMARY | EDIT_UPDATE ); diff --git a/includes/api/ApiMessageTrait.php b/includes/api/ApiMessageTrait.php index ae3b55b90cd0..8d48009825d5 100644 --- a/includes/api/ApiMessageTrait.php +++ b/includes/api/ApiMessageTrait.php @@ -135,7 +135,7 @@ trait ApiMessageTrait { $this->apiData = $data; } - public function serialize() { + public function serialize(): string { return serialize( $this->__serialize() ); } @@ -147,7 +147,7 @@ trait ApiMessageTrait { ]; } - public function unserialize( $serialized ) { + public function unserialize( $serialized ): void { $this->__unserialize( unserialize( $serialized ) ); } diff --git a/includes/language/Message.php b/includes/language/Message.php index 22c11f00b55a..3f599f78b337 100644 --- a/includes/language/Message.php +++ b/includes/language/Message.php @@ -257,7 +257,7 @@ class Message implements MessageSpecifier, Serializable { * @since 1.26 * @return string */ - public function serialize() { + public function serialize(): string { return serialize( $this->__serialize() ); } @@ -289,7 +289,7 @@ class Message implements MessageSpecifier, Serializable { * @since 1.38 * @param string $serialized */ - public function unserialize( $serialized ) { + public function unserialize( $serialized ): void { $this->__unserialize( unserialize( $serialized ) ); } diff --git a/includes/libs/ExplodeIterator.php b/includes/libs/ExplodeIterator.php index b7fb83740cd6..88dfb289d0dd 100644 --- a/includes/libs/ExplodeIterator.php +++ b/includes/libs/ExplodeIterator.php @@ -65,7 +65,7 @@ class ExplodeIterator implements Iterator { $this->rewind(); } - public function rewind() { + public function rewind(): void { $this->curPos = 0; $this->endPos = strpos( $this->subject, $this->delim ); $this->refreshCurrent(); @@ -83,6 +83,10 @@ class ExplodeIterator implements Iterator { } } + /** + * @return string|false + */ + #[\ReturnTypeWillChange] public function current() { return $this->current; } @@ -90,6 +94,7 @@ class ExplodeIterator implements Iterator { /** * @return int|false Current position or boolean false if invalid */ + #[\ReturnTypeWillChange] public function key() { return $this->curPos; } @@ -97,7 +102,7 @@ class ExplodeIterator implements Iterator { /** * @return void */ - public function next() { + public function next(): void { if ( $this->endPos === false ) { $this->curPos = false; } else { @@ -114,7 +119,7 @@ class ExplodeIterator implements Iterator { /** * @return bool */ - public function valid() { + public function valid(): bool { return $this->curPos !== false; } } diff --git a/includes/libs/GenericArrayObject.php b/includes/libs/GenericArrayObject.php index b8cffbee2510..1a0842844a88 100644 --- a/includes/libs/GenericArrayObject.php +++ b/includes/libs/GenericArrayObject.php @@ -92,7 +92,7 @@ abstract class GenericArrayObject extends ArrayObject { * * @param mixed $value */ - public function append( $value ) { + public function append( $value ): void { $this->setElement( null, $value ); } @@ -104,7 +104,7 @@ abstract class GenericArrayObject extends ArrayObject { * @param mixed $index * @param mixed $value */ - public function offsetSet( $index, $value ) { + public function offsetSet( $index, $value ): void { $this->setElement( $index, $value ); } @@ -183,7 +183,7 @@ abstract class GenericArrayObject extends ArrayObject { * * @return string */ - public function serialize() { + public function serialize(): string { return serialize( $this->__serialize() ); } @@ -194,7 +194,7 @@ abstract class GenericArrayObject extends ArrayObject { * * @return array */ - public function __serialize() { + public function __serialize(): array { return $this->getSerializationData(); } @@ -221,7 +221,7 @@ abstract class GenericArrayObject extends ArrayObject { * * @param string $serialization */ - public function unserialize( $serialization ) { + public function unserialize( $serialization ): void { $this->__unserialize( unserialize( $serialization ) ); } @@ -232,7 +232,7 @@ abstract class GenericArrayObject extends ArrayObject { * * @param array $serializationData */ - public function __unserialize( $serializationData ) { + public function __unserialize( $serializationData ): void { foreach ( $serializationData['data'] as $offset => $value ) { // Just set the element, bypassing checks and offset resolving, // as these elements have already gone through this. diff --git a/includes/libs/HashRing.php b/includes/libs/HashRing.php index 174be5a187e0..73325d34661e 100644 --- a/includes/libs/HashRing.php +++ b/includes/libs/HashRing.php @@ -438,7 +438,7 @@ class HashRing implements Serializable { return time(); } - public function serialize() { + public function serialize(): string { return serialize( $this->__serialize() ); } @@ -450,7 +450,7 @@ class HashRing implements Serializable { ]; } - public function unserialize( $serialized ) { + public function unserialize( $serialized ): void { $this->__unserialize( unserialize( $serialized ) ); } diff --git a/includes/libs/MapCacheLRU.php b/includes/libs/MapCacheLRU.php index afe00f4e95db..95d6253658d8 100644 --- a/includes/libs/MapCacheLRU.php +++ b/includes/libs/MapCacheLRU.php @@ -369,7 +369,7 @@ class MapCacheLRU implements ExpirationAwareness, Serializable { ]; } - public function serialize() { + public function serialize(): string { return serialize( $this->__serialize() ); } @@ -381,7 +381,7 @@ class MapCacheLRU implements ExpirationAwareness, Serializable { $this->epoch = $this->getCurrentTime(); } - public function unserialize( $serialized ) { + public function unserialize( $serialized ): void { $this->__unserialize( unserialize( $serialized ) ); } diff --git a/includes/libs/MappedIterator.php b/includes/libs/MappedIterator.php index 3fcb28172586..0b1506e46964 100644 --- a/includes/libs/MappedIterator.php +++ b/includes/libs/MappedIterator.php @@ -64,12 +64,12 @@ class MappedIterator extends FilterIterator { $this->aCallback = $options['accept'] ?? null; } - public function next() { + public function next(): void { $this->cache = []; parent::next(); } - public function rewind() { + public function rewind(): void { $this->rewound = true; $this->cache = []; parent::rewind(); @@ -85,18 +85,20 @@ class MappedIterator extends FilterIterator { return $ok; } + #[\ReturnTypeWillChange] public function key() { $this->init(); return parent::key(); } - public function valid() { + public function valid(): bool { $this->init(); return parent::valid(); } + #[\ReturnTypeWillChange] public function current() { $this->init(); if ( parent::valid() ) { diff --git a/includes/libs/ReverseArrayIterator.php b/includes/libs/ReverseArrayIterator.php index e39c942eaaec..6d6549f50a04 100644 --- a/includes/libs/ReverseArrayIterator.php +++ b/includes/libs/ReverseArrayIterator.php @@ -51,27 +51,29 @@ class ReverseArrayIterator implements Iterator, Countable { $this->rewind(); } + #[\ReturnTypeWillChange] public function current() { return current( $this->array ); } + #[\ReturnTypeWillChange] public function key() { return key( $this->array ); } - public function next() { + public function next(): void { prev( $this->array ); } - public function rewind() { + public function rewind(): void { end( $this->array ); } - public function valid() { + public function valid(): bool { return key( $this->array ) !== null; } - public function count() { + public function count(): int { return count( $this->array ); } } 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 { diff --git a/includes/libs/iterators/IteratorDecorator.php b/includes/libs/iterators/IteratorDecorator.php index 00eca9674e7e..28dfdbd2a5f3 100644 --- a/includes/libs/iterators/IteratorDecorator.php +++ b/includes/libs/iterators/IteratorDecorator.php @@ -38,6 +38,7 @@ abstract class IteratorDecorator implements Iterator { * @inheritDoc * @stable to override */ + #[\ReturnTypeWillChange] public function current() { return $this->iterator->current(); } @@ -46,6 +47,7 @@ abstract class IteratorDecorator implements Iterator { * @inheritDoc * @stable to override */ + #[\ReturnTypeWillChange] public function key() { return $this->iterator->key(); } @@ -54,7 +56,7 @@ abstract class IteratorDecorator implements Iterator { * @inheritDoc * @stable to override */ - public function next() { + public function next(): void { $this->iterator->next(); } @@ -62,7 +64,7 @@ abstract class IteratorDecorator implements Iterator { * @inheritDoc * @stable to override */ - public function rewind() { + public function rewind(): void { $this->iterator->rewind(); } @@ -70,7 +72,7 @@ abstract class IteratorDecorator implements Iterator { * @inheritDoc * @stable to override */ - public function valid() { + public function valid(): bool { return $this->iterator->valid(); } } diff --git a/includes/libs/rdbms/database/DatabaseMysqlBase.php b/includes/libs/rdbms/database/DatabaseMysqlBase.php index 089f23468db5..4cf52a7a1728 100644 --- a/includes/libs/rdbms/database/DatabaseMysqlBase.php +++ b/includes/libs/rdbms/database/DatabaseMysqlBase.php @@ -154,7 +154,7 @@ abstract class DatabaseMysqlBase extends Database { try { $this->currentDomain = new DatabaseDomain( - strlen( $db ) ? $db : null, + $db && strlen( $db ) ? $db : null, null, $tablePrefix ); diff --git a/includes/libs/rdbms/database/position/MySQLPrimaryPos.php b/includes/libs/rdbms/database/position/MySQLPrimaryPos.php index 097a0932787f..f647b2919818 100644 --- a/includes/libs/rdbms/database/position/MySQLPrimaryPos.php +++ b/includes/libs/rdbms/database/position/MySQLPrimaryPos.php @@ -326,7 +326,7 @@ class MySQLPrimaryPos implements DBPrimaryPos { : false; } - public function serialize() { + public function serialize(): string { return serialize( $this->__serialize() ); } @@ -340,7 +340,7 @@ class MySQLPrimaryPos implements DBPrimaryPos { ]; } - public function unserialize( $serialized ) { + public function unserialize( $serialized ): void { $this->__unserialize( unserialize( $serialized ) ); } diff --git a/includes/libs/rdbms/database/resultwrapper/IResultWrapper.php b/includes/libs/rdbms/database/resultwrapper/IResultWrapper.php index 4a1e9be440b9..ff939e4d50f0 100644 --- a/includes/libs/rdbms/database/resultwrapper/IResultWrapper.php +++ b/includes/libs/rdbms/database/resultwrapper/IResultWrapper.php @@ -36,8 +36,7 @@ interface IResultWrapper extends Countable, SeekableIterator { * * @return int */ - #[\ReturnTypeWillChange] - public function count(); + public function count(): int; /** * Fetch the next row from the given result object, in object form. Fields can be retrieved with @@ -65,8 +64,7 @@ interface IResultWrapper extends Countable, SeekableIterator { * @throws OutOfBoundsException * @param int $pos */ - #[\ReturnTypeWillChange] - public function seek( $pos ); + public function seek( $pos ): void; /** * Free a result object @@ -85,8 +83,7 @@ interface IResultWrapper extends Countable, SeekableIterator { /** * @return int */ - #[\ReturnTypeWillChange] - public function key(); + public function key(): int; /** * @return void diff --git a/includes/libs/rdbms/database/resultwrapper/ResultWrapper.php b/includes/libs/rdbms/database/resultwrapper/ResultWrapper.php index 7de4ef0cc3cb..79cec8a87a45 100644 --- a/includes/libs/rdbms/database/resultwrapper/ResultWrapper.php +++ b/includes/libs/rdbms/database/resultwrapper/ResultWrapper.php @@ -95,7 +95,7 @@ abstract class ResultWrapper implements IResultWrapper { return $this->doNumRows(); } - public function count() { + public function count(): int { return $this->doNumRows(); } @@ -111,7 +111,7 @@ abstract class ResultWrapper implements IResultWrapper { return $this->currentRow; } - public function seek( $pos ) { + public function seek( $pos ): void { $numRows = $this->numRows(); // Allow seeking to zero if there are no results $max = $numRows ? $numRows - 1 : 0; @@ -131,11 +131,11 @@ abstract class ResultWrapper implements IResultWrapper { $this->currentRow = false; } - #[\ReturnTypeWillChange] - public function rewind() { + public function rewind(): void { $this->seek( 0 ); } + #[\ReturnTypeWillChange] public function current() { if ( $this->currentRow === null ) { $this->currentRow = $this->fetchObject(); @@ -144,7 +144,7 @@ abstract class ResultWrapper implements IResultWrapper { return $this->currentRow; } - public function key() { + public function key(): int { return $this->currentPos; } @@ -152,8 +152,7 @@ abstract class ResultWrapper implements IResultWrapper { $this->fetchObject(); } - #[\ReturnTypeWillChange] - public function valid() { + public function valid(): bool { return $this->currentPos >= 0 && $this->currentPos < $this->numRows(); } diff --git a/includes/revisionlist/RevisionListBase.php b/includes/revisionlist/RevisionListBase.php index 94fad527865d..4fa7ddabc512 100644 --- a/includes/revisionlist/RevisionListBase.php +++ b/includes/revisionlist/RevisionListBase.php @@ -122,14 +122,15 @@ abstract class RevisionListBase extends ContextSource implements Iterator { return $this->current; } - public function rewind() { + public function rewind(): void { $this->reset(); } /** * Get the current list item, or false if we are at the end - * @return RevisionItemBase + * @return RevisionItemBase|false */ + #[\ReturnTypeWillChange] public function current() { return $this->current; } @@ -139,17 +140,18 @@ abstract class RevisionListBase extends ContextSource implements Iterator { * @return RevisionItemBase * @suppress PhanParamSignatureMismatchInternal */ + #[\ReturnTypeWillChange] public function next() { $this->res->next(); $this->initCurrent(); return $this->current; } - public function key() { + public function key(): int { return $this->res ? $this->res->key() : 0; } - public function valid() { + public function valid(): bool { return $this->res ? $this->res->valid() : false; } diff --git a/includes/search/SearchResultSet.php b/includes/search/SearchResultSet.php index b3d95e26cbcd..0a61f5e80fed 100644 --- a/includes/search/SearchResultSet.php +++ b/includes/search/SearchResultSet.php @@ -69,7 +69,7 @@ class SearchResultSet extends BaseSearchResultSet { return $this->count(); } - final public function count() { + final public function count(): int { return count( $this->extractResults() ); } diff --git a/includes/search/SearchResultSetTrait.php b/includes/search/SearchResultSetTrait.php index 7361265052d0..e98a16d593f3 100644 --- a/includes/search/SearchResultSetTrait.php +++ b/includes/search/SearchResultSetTrait.php @@ -54,7 +54,7 @@ trait SearchResultSetTrait { return null; } - final public function getIterator() { + final public function getIterator(): ArrayIterator { return new ArrayIterator( $this->extractResults() ); } } diff --git a/includes/session/Session.php b/includes/session/Session.php index 1b66f8a75eb3..a7470cc93f0c 100644 --- a/includes/session/Session.php +++ b/includes/session/Session.php @@ -605,8 +605,7 @@ class Session implements \Countable, \Iterator, \ArrayAccess { */ /** @inheritDoc */ - #[\ReturnTypeWillChange] - public function count() { + public function count(): int { $data = &$this->backend->getData(); return count( $data ); } @@ -626,22 +625,19 @@ class Session implements \Countable, \Iterator, \ArrayAccess { } /** @inheritDoc */ - #[\ReturnTypeWillChange] - public function next() { + public function next(): void { $data = &$this->backend->getData(); next( $data ); } /** @inheritDoc */ - #[\ReturnTypeWillChange] - public function rewind() { + public function rewind(): void { $data = &$this->backend->getData(); reset( $data ); } /** @inheritDoc */ - #[\ReturnTypeWillChange] - public function valid() { + public function valid(): bool { $data = &$this->backend->getData(); return key( $data ) !== null; } diff --git a/includes/site/Site.php b/includes/site/Site.php index 5c640613fc69..e84f1c7ce1ea 100644 --- a/includes/site/Site.php +++ b/includes/site/Site.php @@ -672,7 +672,7 @@ class Site implements Serializable { * * @return string */ - public function serialize() { + public function serialize(): string { return serialize( $this->__serialize() ); } @@ -705,7 +705,7 @@ class Site implements Serializable { * * @param string $serialized */ - public function unserialize( $serialized ) { + public function unserialize( $serialized ): void { $this->__unserialize( unserialize( $serialized ) ); } diff --git a/includes/site/SiteList.php b/includes/site/SiteList.php index 931587374dbe..eafe007885a2 100644 --- a/includes/site/SiteList.php +++ b/includes/site/SiteList.php @@ -99,7 +99,7 @@ class SiteList extends GenericArrayObject { * * @param mixed $index */ - public function offsetUnset( $index ) { + public function offsetUnset( $index ): void { if ( $this->offsetExists( $index ) ) { /** * @var Site $site @@ -338,7 +338,7 @@ class SiteList extends GenericArrayObject { * * @param array $serializationData */ - public function __unserialize( $serializationData ) { + public function __unserialize( $serializationData ): void { parent::__unserialize( $serializationData ); $this->byInternalId = $serializationData['internalIds']; diff --git a/includes/user/UserArrayFromResult.php b/includes/user/UserArrayFromResult.php index 35ca5582a7e5..c8e9d68de37c 100644 --- a/includes/user/UserArrayFromResult.php +++ b/includes/user/UserArrayFromResult.php @@ -56,7 +56,7 @@ class UserArrayFromResult extends UserArray implements Countable { /** * @return int */ - public function count() { + public function count(): int { return $this->res->numRows(); } @@ -68,13 +68,13 @@ class UserArrayFromResult extends UserArray implements Countable { return $this->key; } - public function next() { + public function next(): void { $row = $this->res->fetchObject(); $this->setCurrent( $row ); $this->key++; } - public function rewind() { + public function rewind(): void { $this->res->rewind(); $this->key = 0; $this->setCurrent( $this->res->current() ); @@ -83,7 +83,7 @@ class UserArrayFromResult extends UserArray implements Countable { /** * @return bool */ - public function valid() { + public function valid(): bool { return $this->current !== false; } } diff --git a/includes/utils/BatchRowIterator.php b/includes/utils/BatchRowIterator.php index c329a4d224b5..74c0e340cbcf 100644 --- a/includes/utils/BatchRowIterator.php +++ b/includes/utils/BatchRowIterator.php @@ -81,7 +81,7 @@ class BatchRowIterator implements RecursiveIterator { /** * @var int 0-indexed number of pages fetched since self::reset() */ - private $key; + private $key = -1; /** * @var array Additional query options @@ -186,21 +186,21 @@ class BatchRowIterator implements RecursiveIterator { /** * @return array The most recently fetched set of rows from the database */ - public function current() { + public function current(): array { return $this->current; } /** * @return int 0-indexed count of the page number fetched */ - public function key() { + public function key(): int { return $this->key; } /** * Reset the iterator to the beginning of the table. */ - public function rewind() { + public function rewind(): void { $this->key = -1; // self::next() will turn this into 0 $this->current = []; $this->next(); @@ -209,7 +209,7 @@ class BatchRowIterator implements RecursiveIterator { /** * @return bool True when the iterator is in a valid state */ - public function valid() { + public function valid(): bool { return (bool)$this->current; } @@ -230,7 +230,7 @@ class BatchRowIterator implements RecursiveIterator { /** * Fetch the next set of rows from the database. */ - public function next() { + public function next(): void { $caller = __METHOD__; if ( (string)$this->caller !== '' ) { $caller .= " (for {$this->caller})"; |