Use explicit nullable type on parameter arguments (for PHP 8.4)

Implicitly marking parameter $... as nullable is deprecated in PHP
8.4. The explicit nullable type must be used instead.

Bug: T376276
Change-Id: Idcd0b50c1c01a33c4cabeed3e31828f77c3f6443
This commit is contained in:
Andre Klapper 2024-10-26 15:15:18 +02:00
parent 47edd9b21d
commit 5c6bc704a2
7 changed files with 18 additions and 18 deletions

View file

@ -75,7 +75,7 @@ class InputCheckFactory {
* @return RestbaseChecker checker based on communication with restbase interface
*/
public function newRestbaseChecker( string $input, string $type,
MathRestbaseInterface &$restbaseInterface = null ): RestbaseChecker {
?MathRestbaseInterface &$restbaseInterface = null ): RestbaseChecker {
return new RestbaseChecker(
$input,
$type,
@ -111,7 +111,7 @@ class InputCheckFactory {
*/
public function newDefaultChecker( string $input,
string $type,
MathRestbaseInterface &$restbaseInterface = null,
?MathRestbaseInterface &$restbaseInterface = null,
bool $purge = false ): BaseChecker {
switch ( $this->texVCmode ) {
case "mathoid":

View file

@ -20,12 +20,12 @@ final class Math {
// should not be instantiated
}
public static function getMathConfig( ContainerInterface $services = null ): MathConfig {
public static function getMathConfig( ?ContainerInterface $services = null ): MathConfig {
return ( $services ?: MediaWikiServices::getInstance() )
->get( 'Math.Config' );
}
public static function getCheckerFactory( ContainerInterface $services = null ): InputCheckFactory {
public static function getCheckerFactory( ?ContainerInterface $services = null ): InputCheckFactory {
return ( $services ?: MediaWikiServices::getInstance() )
->get( 'Math.CheckerFactory' );
}

View file

@ -51,7 +51,7 @@ class MathWikibaseInfo {
* @param EntityId $entityId
* @param MathFormatter|null $mathFormatter to format math equations. Default format is HTML.
*/
public function __construct( EntityId $entityId, MathFormatter $mathFormatter = null ) {
public function __construct( EntityId $entityId, ?MathFormatter $mathFormatter = null ) {
$this->id = $entityId;
$this->mathFormatter = $mathFormatter ?: new MathFormatter( SnakFormatter::FORMAT_HTML );
}

View file

@ -17,7 +17,7 @@ class MathConfigTest extends TestCase {
private function newMathConfig(
array $configOverrides,
ExtensionRegistry $registry = null
?ExtensionRegistry $registry = null
): MathConfig {
return new MathConfig(
new ServiceOptions( MathConfig::CONSTRUCTOR_OPTIONS, $configOverrides + [

View file

@ -64,8 +64,8 @@ class MathWikibaseConnectorTestFactory extends MediaWikiUnitTestCase {
public function getWikibaseConnectorWithExistingItems(
EntityRevision $entityRevision,
bool $storageExceptionOnQ3 = false,
LoggerInterface $logger = null,
EntityIdParser $parser = null
?LoggerInterface $logger = null,
?EntityIdParser $parser = null
): MathWikibaseConnector {
$revisionLookupMock = $this->createMock( EntityRevisionLookup::class );
$revisionLookupMock->method( 'getEntityRevision' )->willReturnCallback(
@ -105,12 +105,12 @@ class MathWikibaseConnectorTestFactory extends MediaWikiUnitTestCase {
}
public function getWikibaseConnector(
LanguageFactory $languageFactory = null,
LanguageNameUtils $languageNameUtils = null,
FallbackLabelDescriptionLookupFactory $labelDescriptionLookupFactory = null,
EntityRevisionLookup $entityRevisionLookupMock = null,
LoggerInterface $logger = null,
EntityIdParser $parser = null
?LanguageFactory $languageFactory = null,
?LanguageNameUtils $languageNameUtils = null,
?FallbackLabelDescriptionLookupFactory $labelDescriptionLookupFactory = null,
?EntityRevisionLookup $entityRevisionLookupMock = null,
?LoggerInterface $logger = null,
?EntityIdParser $parser = null
): MathWikibaseConnector {
$labelDescriptionLookupFactory = $labelDescriptionLookupFactory ?:
$this->createMock( FallbackLabelDescriptionLookupFactory::class );

View file

@ -111,9 +111,9 @@ class PopupTest extends MathWikibaseConnectorTestFactory {
}
private function getPopup(
LanguageFactory $languageFactoryMock = null,
LanguageNameUtils $languageNameUtilsMock = null,
Item $item = null
?LanguageFactory $languageFactoryMock = null,
?LanguageNameUtils $languageNameUtilsMock = null,
?Item $item = null
): Popup {
$languageFactoryMock = $languageFactoryMock ?: $this->createMock( LanguageFactory::class );
if ( !$languageNameUtilsMock ) {

View file

@ -43,7 +43,7 @@ class RenderTest extends MediaWikiUnitTestCase {
/**
* @dataProvider provideTestCases
*/
public function testRendering( string $in, string $out = null ) {
public function testRendering( string $in, ?string $out = null ) {
$parser = new Parser();
$out ??= $in;