diff options
author | Doğu Abaris <abaris@null.net> | 2024-11-13 17:57:25 +0100 |
---|---|---|
committer | Bartosz Dziewoński <dziewonski@fastmail.fm> | 2024-11-21 23:09:57 +0100 |
commit | 77f5e658d7ecb4872dda27a8d5ff2d1132f001a4 (patch) | |
tree | 2b2dbac338796e47671734266d1d6e069f5a3707 | |
parent | 84af03ba741dea4152c070dc7ad6812001b92d08 (diff) | |
download | mediawikicore-77f5e658d7ecb4872dda27a8d5ff2d1132f001a4.tar.gz mediawikicore-77f5e658d7ecb4872dda27a8d5ff2d1132f001a4.zip |
includes/libs/Message: Add return type hints, update methods
Applied return type hints to improve type safety in Message classes.
Adjusted constructors to specify parameter types for consistency.
Enhanced `newFromJsonArray` in `ScalarParam`, `DataMessageValue`,
and `MessageParam` to clarify deserialization logic.
Key updates:
- Added `: string` return types for `getLangCode`, `getKey`, `dump`.
- Added `: array` return type for `getParams`, `getData`, `toJsonArray`.
- Revised `ScalarParam` JSON parsing to ensure a consistent return.
These adjustments enhance type safety across the Message classes.
Depends-On: Id7cc576693f5f1830e1d261cb13c626c901fb40f
Depends-On: I260e3f526be10f7b11e5c77a1e300590c6fc5b2b
Depends-On: I3c318273856d15407c71cb9b4ab7c23a0debb314
Change-Id: I7e50be91c01b4b70e1d1380651f001e35bd60523
19 files changed, 88 insertions, 80 deletions
diff --git a/RELEASE-NOTES-1.44 b/RELEASE-NOTES-1.44 index 3f6091e3204f..795f2c5699bb 100644 --- a/RELEASE-NOTES-1.44 +++ b/RELEASE-NOTES-1.44 @@ -116,6 +116,12 @@ because of Phabricator reports. * The MediaWiki\Message\Converter class, deprecated in 1.43, has been removed. Use MessageValue::newFromSpecifier or Message::newFromSpecifier instead (T358779). +* Return type declarations were added to methods in `includes/libs/Message`, + specifically in the `MessageSpecifier`, `ITextFormatter`, and + `IMessageFormatterFactory` interfaces. This update enhances type safety but + may require updates in any classes implementing these interfaces, including + external extensions. Extensions such as Translate, Flow, and ReadingLists + require compatibility patches to support these changes. * The ParsoidOutputAccess class marked @unstable from creation and deprecated with all of its methods in 1.43, has been removed. * IDatabase::onAtomicSectionCancel() has been removed without deprecation diff --git a/includes/language/Message/Message.php b/includes/language/Message/Message.php index 0e219122e1b2..4fba5d6c7f06 100644 --- a/includes/language/Message/Message.php +++ b/includes/language/Message/Message.php @@ -399,7 +399,7 @@ class Message implements Stringable, MessageSpecifier, Serializable { * * @return string */ - public function getKey() { + public function getKey(): string { return $this->key; } @@ -410,7 +410,7 @@ class Message implements Stringable, MessageSpecifier, Serializable { * * @return (MessageParam|Message|string|int|float)[] */ - public function getParams() { + public function getParams(): array { return $this->parameters; } diff --git a/includes/language/Message/MessageFormatterFactory.php b/includes/language/Message/MessageFormatterFactory.php index 344934ddcab0..25a1d66a15c2 100644 --- a/includes/language/Message/MessageFormatterFactory.php +++ b/includes/language/Message/MessageFormatterFactory.php @@ -31,7 +31,7 @@ class MessageFormatterFactory implements IMessageFormatterFactory { /** * @inheritDoc */ - public function getTextFormatter( $langCode ): ITextFormatter { + public function getTextFormatter( string $langCode ): ITextFormatter { if ( !isset( $this->textFormatters[$langCode] ) ) { $this->textFormatters[$langCode] = new TextFormatter( $langCode, $this->format ); diff --git a/includes/language/Message/TextFormatter.php b/includes/language/Message/TextFormatter.php index e463aef0d74e..244c74c4f9ea 100644 --- a/includes/language/Message/TextFormatter.php +++ b/includes/language/Message/TextFormatter.php @@ -33,7 +33,7 @@ class TextFormatter implements ITextFormatter { $this->format = $format; } - public function getLangCode() { + public function getLangCode(): string { return $this->langCode; } diff --git a/includes/language/RawMessage.php b/includes/language/RawMessage.php index 3c889d11bc29..b2ee93d86f5d 100644 --- a/includes/language/RawMessage.php +++ b/includes/language/RawMessage.php @@ -80,7 +80,7 @@ class RawMessage extends Message { * which is a real message key that can be used with MessageValue and other classes. * @return string */ - public function getKey() { + public function getKey(): string { return 'rawmessage'; } @@ -89,7 +89,7 @@ class RawMessage extends Message { * 'rawmessage' message, and can be used with MessageValue and other classes. * @return string[] */ - public function getParams() { + public function getParams(): array { // If the provided text is equivalent to 'rawmessage', return the provided params. if ( $this->key === '$1' ) { return $this->parameters; diff --git a/includes/libs/Message/DataMessageValue.php b/includes/libs/Message/DataMessageValue.php index 710af0a349c6..79d716af8f67 100644 --- a/includes/libs/Message/DataMessageValue.php +++ b/includes/libs/Message/DataMessageValue.php @@ -25,11 +25,8 @@ use Wikimedia\JsonCodec\JsonCodecableTrait; class DataMessageValue extends MessageValue { use JsonCodecableTrait; - /** @var string */ - private $code; - - /** @var array|null */ - private $data; + private string $code; + private ?array $data; /** * @stable to call @@ -41,7 +38,7 @@ class DataMessageValue extends MessageValue { * @param array|null $data Structured data representing the concept * behind this message. */ - public function __construct( $key, $params = [], $code = null, ?array $data = null ) { + public function __construct( string $key, array $params = [], ?string $code = null, ?array $data = null ) { parent::__construct( $key, $params ); $this->code = $code ?? $key; @@ -50,13 +47,20 @@ class DataMessageValue extends MessageValue { /** * Static constructor for easier chaining of `->params()` methods + * * @param string $key * @param (MessageParam|MessageValue|string|int|float)[] $params * @param string|null $code * @param array|null $data + * * @return DataMessageValue */ - public static function new( $key, $params = [], $code = null, ?array $data = null ) { + public static function new( + string $key, + array $params = [], + ?string $code = null, + ?array $data = null + ): DataMessageValue { return new DataMessageValue( $key, $params, $code, $data ); } @@ -64,7 +68,7 @@ class DataMessageValue extends MessageValue { * Get the message code * @return string */ - public function getCode() { + public function getCode(): string { return $this->code; } @@ -72,11 +76,11 @@ class DataMessageValue extends MessageValue { * Get the message's structured data * @return array|null */ - public function getData() { + public function getData(): ?array { return $this->data; } - public function dump() { + public function dump(): string { $contents = ''; if ( $this->getParams() ) { $contents = '<params>'; @@ -100,12 +104,12 @@ class DataMessageValue extends MessageValue { // WARNING: When changing how this class is serialized, follow the instructions // at <https://www.mediawiki.org/wiki/Manual:Parser_cache/Serialization_compatibility>! return parent::toJsonArray() + [ - 'code' => $this->code, - 'data' => $this->data, - ]; + 'code' => $this->code, + 'data' => $this->data, + ]; } - public static function newFromJsonArray( array $json ) { + public static function newFromJsonArray( array $json ): DataMessageValue { // WARNING: When changing how this class is serialized, follow the instructions // at <https://www.mediawiki.org/wiki/Manual:Parser_cache/Serialization_compatibility>! return new self( $json['key'], $json['params'], $json['code'], $json['data'] ); diff --git a/includes/libs/Message/IMessageFormatterFactory.php b/includes/libs/Message/IMessageFormatterFactory.php index 337ea82436d4..59ed05cef55d 100644 --- a/includes/libs/Message/IMessageFormatterFactory.php +++ b/includes/libs/Message/IMessageFormatterFactory.php @@ -14,5 +14,5 @@ interface IMessageFormatterFactory { * @param string $langCode The language code * @return ITextFormatter */ - public function getTextFormatter( $langCode ): ITextFormatter; + public function getTextFormatter( string $langCode ): ITextFormatter; } diff --git a/includes/libs/Message/ITextFormatter.php b/includes/libs/Message/ITextFormatter.php index fa71a26a95f6..9d6ac9ea597e 100644 --- a/includes/libs/Message/ITextFormatter.php +++ b/includes/libs/Message/ITextFormatter.php @@ -20,7 +20,7 @@ interface ITextFormatter { * Get the internal language code in which format() is * @return string */ - public function getLangCode(); + public function getLangCode(): string; /** * Convert a MessageSpecifier to text. diff --git a/includes/libs/Message/ListParam.php b/includes/libs/Message/ListParam.php index 058bc8525938..27435d7ec641 100644 --- a/includes/libs/Message/ListParam.php +++ b/includes/libs/Message/ListParam.php @@ -15,8 +15,7 @@ use Wikimedia\JsonCodec\JsonCodecableTrait; class ListParam extends MessageParam { use JsonCodecableTrait; - /** @var string */ - private $listType; + private string $listType; /** * @stable to call. @@ -25,7 +24,7 @@ class ListParam extends MessageParam { * @param (MessageParam|MessageSpecifier|string|int|float)[] $elements Values in the list. * Values that are not instances of MessageParam are wrapped using ParamType::TEXT. */ - public function __construct( $listType, array $elements ) { + public function __construct( string $listType, array $elements ) { if ( !in_array( $listType, ListType::cases() ) ) { throw new InvalidArgumentException( '$listType must be one of the ListType constants' ); } @@ -46,16 +45,16 @@ class ListParam extends MessageParam { * * @return string One of the ListType constants */ - public function getListType() { + public function getListType(): string { return $this->listType; } - public function dump() { + public function dump(): string { $contents = ''; foreach ( $this->value as $element ) { $contents .= $element->dump(); } - return "<{$this->type} listType=\"{$this->listType}\">$contents</{$this->type}>"; + return "<$this->type listType=\"$this->listType\">$contents</$this->type>"; } public function toJsonArray(): array { @@ -67,7 +66,7 @@ class ListParam extends MessageParam { ]; } - public static function newFromJsonArray( array $json ) { + public static function newFromJsonArray( array $json ): ListParam { // WARNING: When changing how this class is serialized, follow the instructions // at <https://www.mediawiki.org/wiki/Manual:Parser_cache/Serialization_compatibility>! if ( count( $json ) !== 2 || !isset( $json[ParamType::LIST] ) || !isset( $json['type'] ) ) { diff --git a/includes/libs/Message/MessageParam.php b/includes/libs/Message/MessageParam.php index 2292b6181db6..fc26a318c4e2 100644 --- a/includes/libs/Message/MessageParam.php +++ b/includes/libs/Message/MessageParam.php @@ -11,8 +11,7 @@ use Wikimedia\JsonCodec\JsonCodecable; */ abstract class MessageParam implements JsonCodecable { - /** @var string */ - protected $type; + protected string $type; /** @var mixed */ protected $value; @@ -21,7 +20,7 @@ abstract class MessageParam implements JsonCodecable { * * @return string One of the ParamType constants */ - public function getType() { + public function getType(): string { return $this->type; } @@ -39,5 +38,5 @@ abstract class MessageParam implements JsonCodecable { * * @return string */ - abstract public function dump(); + abstract public function dump(): string; } diff --git a/includes/libs/Message/MessageSpecifier.php b/includes/libs/Message/MessageSpecifier.php index 843e431a8b18..dea4b975df0b 100644 --- a/includes/libs/Message/MessageSpecifier.php +++ b/includes/libs/Message/MessageSpecifier.php @@ -33,14 +33,14 @@ interface MessageSpecifier { * * @return string */ - public function getKey(); + public function getKey(): string; /** * Returns the message parameters * * @return (MessageParam|MessageSpecifier|string|int|float)[] */ - public function getParams(); + public function getParams(): array; } /** diff --git a/includes/libs/Message/MessageValue.php b/includes/libs/Message/MessageValue.php index ca25cca2c3c9..79ad579a8a60 100644 --- a/includes/libs/Message/MessageValue.php +++ b/includes/libs/Message/MessageValue.php @@ -19,11 +19,10 @@ use Wikimedia\JsonCodec\JsonCodecableTrait; class MessageValue implements MessageSpecifier, JsonCodecable { use JsonCodecableTrait; - /** @var string */ - private $key; + private string $key; /** @var MessageParam[] */ - private $params; + private array $params; /** * @stable to call @@ -32,7 +31,7 @@ class MessageValue implements MessageSpecifier, JsonCodecable { * @param (MessageParam|MessageSpecifier|string|int|float)[] $params Values that are not instances * of MessageParam are wrapped using ParamType::TEXT. */ - public function __construct( $key, $params = [] ) { + public function __construct( string $key, array $params = [] ) { $this->key = $key; $this->params = []; $this->params( ...$params ); @@ -44,7 +43,7 @@ class MessageValue implements MessageSpecifier, JsonCodecable { * @param (MessageParam|MessageSpecifier|string|int|float)[] $params * @return MessageValue */ - public static function new( $key, $params = [] ) { + public static function new( string $key, array $params = [] ): MessageValue { return new MessageValue( $key, $params ); } @@ -57,7 +56,7 @@ class MessageValue implements MessageSpecifier, JsonCodecable { * @param MessageSpecifier $spec * @return MessageValue */ - public static function newFromSpecifier( MessageSpecifier $spec ) { + public static function newFromSpecifier( MessageSpecifier $spec ): MessageValue { if ( $spec instanceof MessageValue ) { return $spec; } @@ -69,7 +68,7 @@ class MessageValue implements MessageSpecifier, JsonCodecable { * * @return string */ - public function getKey() { + public function getKey(): string { return $this->key; } @@ -78,7 +77,7 @@ class MessageValue implements MessageSpecifier, JsonCodecable { * * @return MessageParam[] */ - public function getParams() { + public function getParams(): array { return $this->params; } @@ -88,7 +87,7 @@ class MessageValue implements MessageSpecifier, JsonCodecable { * @param MessageParam|MessageSpecifier|string|int|float ...$values * @return $this */ - public function params( ...$values ) { + public function params( ...$values ): MessageValue { foreach ( $values as $value ) { if ( $value instanceof MessageParam ) { $this->params[] = $value; @@ -106,7 +105,7 @@ class MessageValue implements MessageSpecifier, JsonCodecable { * @param MessageSpecifier|string|int|float ...$values Scalar values * @return $this */ - public function textParamsOfType( $type, ...$values ) { + public function textParamsOfType( string $type, ...$values ): MessageValue { foreach ( $values as $value ) { $this->params[] = new ScalarParam( $type, $value ); } @@ -121,7 +120,7 @@ class MessageValue implements MessageSpecifier, JsonCodecable { * is an array of items suitable to pass as $params to ListParam::__construct() * @return $this */ - public function listParamsOfType( $listType, ...$values ) { + public function listParamsOfType( string $listType, ...$values ): MessageValue { foreach ( $values as $value ) { $this->params[] = new ListParam( $listType, $value ); } @@ -134,7 +133,7 @@ class MessageValue implements MessageSpecifier, JsonCodecable { * @param MessageSpecifier|string|int|float ...$values * @return $this */ - public function textParams( ...$values ) { + public function textParams( ...$values ): MessageValue { return $this->textParamsOfType( ParamType::TEXT, ...$values ); } @@ -144,7 +143,7 @@ class MessageValue implements MessageSpecifier, JsonCodecable { * @param int|float ...$values * @return $this */ - public function numParams( ...$values ) { + public function numParams( ...$values ): MessageValue { return $this->textParamsOfType( ParamType::NUM, ...$values ); } @@ -158,7 +157,7 @@ class MessageValue implements MessageSpecifier, JsonCodecable { * @param int|float ...$values * @return $this */ - public function longDurationParams( ...$values ) { + public function longDurationParams( ...$values ): MessageValue { return $this->textParamsOfType( ParamType::DURATION_LONG, ...$values ); } @@ -172,7 +171,7 @@ class MessageValue implements MessageSpecifier, JsonCodecable { * @param int|float ...$values * @return $this */ - public function shortDurationParams( ...$values ) { + public function shortDurationParams( ...$values ): MessageValue { return $this->textParamsOfType( ParamType::DURATION_SHORT, ...$values ); } @@ -183,7 +182,7 @@ class MessageValue implements MessageSpecifier, JsonCodecable { * or "infinity" * @return $this */ - public function expiryParams( ...$values ) { + public function expiryParams( ...$values ): MessageValue { return $this->textParamsOfType( ParamType::EXPIRY, ...$values ); } @@ -194,7 +193,7 @@ class MessageValue implements MessageSpecifier, JsonCodecable { * @param string ...$values Timestamp as accepted by the Wikimedia\Timestamp library. * @return $this */ - public function dateTimeParams( ...$values ) { + public function dateTimeParams( ...$values ): MessageValue { return $this->textParamsOfType( ParamType::DATETIME, ...$values ); } @@ -205,7 +204,7 @@ class MessageValue implements MessageSpecifier, JsonCodecable { * @param string ...$values Timestamp as accepted by the Wikimedia\Timestamp library. * @return $this */ - public function dateParams( ...$values ) { + public function dateParams( ...$values ): MessageValue { return $this->textParamsOfType( ParamType::DATE, ...$values ); } @@ -216,7 +215,7 @@ class MessageValue implements MessageSpecifier, JsonCodecable { * @param string ...$values Timestamp as accepted by the Wikimedia\Timestamp library. * @return $this */ - public function timeParams( ...$values ) { + public function timeParams( ...$values ): MessageValue { return $this->textParamsOfType( ParamType::TIME, ...$values ); } @@ -227,7 +226,7 @@ class MessageValue implements MessageSpecifier, JsonCodecable { * @param string ...$values User Groups * @return $this */ - public function userGroupParams( ...$values ) { + public function userGroupParams( ...$values ): MessageValue { return $this->textParamsOfType( ParamType::GROUP, ...$values ); } @@ -237,7 +236,7 @@ class MessageValue implements MessageSpecifier, JsonCodecable { * @param int ...$values * @return $this */ - public function sizeParams( ...$values ) { + public function sizeParams( ...$values ): MessageValue { return $this->textParamsOfType( ParamType::SIZE, ...$values ); } @@ -248,7 +247,7 @@ class MessageValue implements MessageSpecifier, JsonCodecable { * @param int|float ...$values * @return $this */ - public function bitrateParams( ...$values ) { + public function bitrateParams( ...$values ): MessageValue { return $this->textParamsOfType( ParamType::BITRATE, ...$values ); } @@ -262,7 +261,7 @@ class MessageValue implements MessageSpecifier, JsonCodecable { * @param string ...$values * @return $this */ - public function rawParams( ...$values ) { + public function rawParams( ...$values ): MessageValue { return $this->textParamsOfType( ParamType::RAW, ...$values ); } @@ -276,7 +275,7 @@ class MessageValue implements MessageSpecifier, JsonCodecable { * @param string ...$values * @return $this */ - public function plaintextParams( ...$values ) { + public function plaintextParams( ...$values ): MessageValue { return $this->textParamsOfType( ParamType::PLAINTEXT, ...$values ); } @@ -290,7 +289,7 @@ class MessageValue implements MessageSpecifier, JsonCodecable { * is an array of items suitable to pass as $params to ListParam::__construct() * @return $this */ - public function commaListParams( ...$values ) { + public function commaListParams( ...$values ): MessageValue { return $this->listParamsOfType( ListType::COMMA, ...$values ); } @@ -304,7 +303,7 @@ class MessageValue implements MessageSpecifier, JsonCodecable { * is an array of items suitable to pass as $params to ListParam::__construct() * @return $this */ - public function semicolonListParams( ...$values ) { + public function semicolonListParams( ...$values ): MessageValue { return $this->listParamsOfType( ListType::SEMICOLON, ...$values ); } @@ -318,7 +317,7 @@ class MessageValue implements MessageSpecifier, JsonCodecable { * is an array of items suitable to pass as $params to ListParam::__construct() * @return $this */ - public function pipeListParams( ...$values ) { + public function pipeListParams( ...$values ): MessageValue { return $this->listParamsOfType( ListType::PIPE, ...$values ); } @@ -332,7 +331,7 @@ class MessageValue implements MessageSpecifier, JsonCodecable { * @param (MessageParam|string)[] ...$values * @return $this */ - public function textListParams( ...$values ) { + public function textListParams( ...$values ): MessageValue { return $this->listParamsOfType( ListType::AND, ...$values ); } @@ -341,7 +340,7 @@ class MessageValue implements MessageSpecifier, JsonCodecable { * * @return string */ - public function dump() { + public function dump(): string { $contents = ''; foreach ( $this->params as $param ) { $contents .= $param->dump(); @@ -359,7 +358,7 @@ class MessageValue implements MessageSpecifier, JsonCodecable { ]; } - public static function newFromJsonArray( array $json ) { + public static function newFromJsonArray( array $json ): MessageValue { // WARNING: When changing how this class is serialized, follow the instructions // at <https://www.mediawiki.org/wiki/Manual:Parser_cache/Serialization_compatibility>! return new self( $json['key'], $json['params'] ); diff --git a/includes/libs/Message/ScalarParam.php b/includes/libs/Message/ScalarParam.php index 82f6eb4dc56f..e698367ab405 100644 --- a/includes/libs/Message/ScalarParam.php +++ b/includes/libs/Message/ScalarParam.php @@ -24,7 +24,7 @@ class ScalarParam extends MessageParam { * @param string $type One of the ParamType constants. * @param string|int|float|MessageSpecifier|Stringable $value */ - public function __construct( $type, $value ) { + public function __construct( string $type, $value ) { if ( !in_array( $type, ParamType::cases() ) ) { throw new InvalidArgumentException( '$type must be one of the ParamType constants' ); } @@ -57,13 +57,13 @@ class ScalarParam extends MessageParam { $this->value = $value; } - public function dump() { + public function dump(): string { if ( $this->value instanceof MessageValue ) { $contents = $this->value->dump(); } else { $contents = htmlspecialchars( (string)$this->value ); } - return "<{$this->type}>" . $contents . "</{$this->type}>"; + return "<$this->type>" . $contents . "</$this->type>"; } public function toJsonArray(): array { @@ -74,15 +74,16 @@ class ScalarParam extends MessageParam { ]; } - public static function newFromJsonArray( array $json ) { + public static function newFromJsonArray( array $json ): ScalarParam { // WARNING: When changing how this class is serialized, follow the instructions // at <https://www.mediawiki.org/wiki/Manual:Parser_cache/Serialization_compatibility>! if ( count( $json ) !== 1 ) { throw new InvalidArgumentException( 'Invalid format' ); } - // Use a dummy loop to get the first (and only) key/value pair in the array. - foreach ( $json as $type => $value ) { - return new self( $type, $value ); - } + + $type = key( $json ); + $value = current( $json ); + + return new self( $type, $value ); } } diff --git a/includes/libs/rdbms/exception/DBExpectedError.php b/includes/libs/rdbms/exception/DBExpectedError.php index 4397fc293da9..f37c191e4102 100644 --- a/includes/libs/rdbms/exception/DBExpectedError.php +++ b/includes/libs/rdbms/exception/DBExpectedError.php @@ -47,11 +47,11 @@ class DBExpectedError extends DBError implements MessageSpecifier { $this->params = $params; } - public function getKey() { + public function getKey(): string { return 'databaseerror-text'; } - public function getParams() { + public function getParams(): array { return $this->params; } } diff --git a/includes/libs/rdbms/exception/DBQueryTimeoutError.php b/includes/libs/rdbms/exception/DBQueryTimeoutError.php index 8317ad0d2486..546381deaceb 100644 --- a/includes/libs/rdbms/exception/DBQueryTimeoutError.php +++ b/includes/libs/rdbms/exception/DBQueryTimeoutError.php @@ -45,7 +45,7 @@ class DBQueryTimeoutError extends DBQueryError { parent::__construct( $db, $error, $errno, $sql, $fname, $message ); } - public function getKey() { + public function getKey(): string { return 'transaction-max-statement-time-exceeded'; } diff --git a/includes/libs/rdbms/exception/DBTransactionSizeError.php b/includes/libs/rdbms/exception/DBTransactionSizeError.php index bea1300c5b08..64b454e42139 100644 --- a/includes/libs/rdbms/exception/DBTransactionSizeError.php +++ b/includes/libs/rdbms/exception/DBTransactionSizeError.php @@ -24,7 +24,7 @@ namespace Wikimedia\Rdbms; * @ingroup Database */ class DBTransactionSizeError extends DBTransactionError { - public function getKey() { + public function getKey(): string { return 'transaction-duration-limit-exceeded'; } } diff --git a/tests/phpunit/integration/includes/Rest/Handler/DiscoveryHandlerTest.php b/tests/phpunit/integration/includes/Rest/Handler/DiscoveryHandlerTest.php index e99e3da3abc7..429e86646c6a 100644 --- a/tests/phpunit/integration/includes/Rest/Handler/DiscoveryHandlerTest.php +++ b/tests/phpunit/integration/includes/Rest/Handler/DiscoveryHandlerTest.php @@ -46,7 +46,7 @@ class DiscoveryHandlerTest extends MediaWikiIntegrationTestCase { ); $formatter = new class implements ITextFormatter { - public function getLangCode() { + public function getLangCode(): string { return 'qqx'; } diff --git a/tests/phpunit/integration/includes/Rest/Handler/ModuleSpecHandlerTest.php b/tests/phpunit/integration/includes/Rest/Handler/ModuleSpecHandlerTest.php index e58b6d3fbff5..3a2695894f33 100644 --- a/tests/phpunit/integration/includes/Rest/Handler/ModuleSpecHandlerTest.php +++ b/tests/phpunit/integration/includes/Rest/Handler/ModuleSpecHandlerTest.php @@ -48,7 +48,7 @@ class ModuleSpecHandlerTest extends MediaWikiIntegrationTestCase { ); $formatter = new class implements ITextFormatter { - public function getLangCode() { + public function getLangCode(): string { return 'qqx'; } diff --git a/tests/phpunit/mocks/DummyServicesTrait.php b/tests/phpunit/mocks/DummyServicesTrait.php index 99272229537a..160c0386b8ae 100644 --- a/tests/phpunit/mocks/DummyServicesTrait.php +++ b/tests/phpunit/mocks/DummyServicesTrait.php @@ -471,7 +471,7 @@ trait DummyServicesTrait { $this->dumpMessages = $dumpMessages; } - public function getLangCode() { + public function getLangCode(): string { return 'qqx'; } |