From 7b212efcacf6a36e813687dc1a7b095108ace1d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartosz=20Dziewo=C5=84ski?= Date: Tue, 17 Sep 2024 22:46:25 +0200 Subject: [PATCH] Replace some manual checks and exceptions with type hints Noticed while reviewing I2e640b9737cb68090a8e1cb70067d1b74037d647. Change-Id: I9b95b56ffd64cc438d5071046a9f038e4d3dc799 --- includes/api/ApiModuleManager.php | 10 +--------- includes/language/RawMessage.php | 7 +------ 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/includes/api/ApiModuleManager.php b/includes/api/ApiModuleManager.php index ebbe663fae1..47617114cda 100644 --- a/includes/api/ApiModuleManager.php +++ b/includes/api/ApiModuleManager.php @@ -98,15 +98,7 @@ class ApiModuleManager extends ContextSource { * or a class name to instantiate. * @param callable|null $factory Callback for instantiating the module (deprecated). */ - public function addModule( $name, $group, $spec, $factory = null ) { - if ( !is_string( $name ) ) { - throw new InvalidArgumentException( '$name must be a string' ); - } - - if ( !is_string( $group ) ) { - throw new InvalidArgumentException( '$group must be a string' ); - } - + public function addModule( string $name, string $group, $spec, $factory = null ) { if ( is_string( $spec ) ) { $spec = [ 'class' => $spec diff --git a/includes/language/RawMessage.php b/includes/language/RawMessage.php index 90e4e844a9d..3c889d11bc2 100644 --- a/includes/language/RawMessage.php +++ b/includes/language/RawMessage.php @@ -20,7 +20,6 @@ namespace MediaWiki\Language; -use InvalidArgumentException; use MediaWiki\Message\Message; /** @@ -49,11 +48,7 @@ class RawMessage extends Message { * @param string $text Message to use. * @param array $params Parameters for the message. */ - public function __construct( $text, $params = [] ) { - if ( !is_string( $text ) ) { - throw new InvalidArgumentException( '$text must be a string' ); - } - + public function __construct( string $text, $params = [] ) { parent::__construct( $text, $params ); // The key is the message.