From ce0e5b61de566d49859199d800a72aa2eac2628a Mon Sep 17 00:00:00 2001 From: Reedy Date: Sun, 27 Oct 2024 20:34:32 +0000 Subject: [PATCH] Use explicit nullable type on parameter arguments Bug: T376276 Change-Id: I0413ac75ecc340a8e6844a351ddb838288cbb5b8 --- src/Control/SubmitControl.php | 4 ++-- src/Repository/AccessTokenRepository.php | 2 +- src/SessionProvider.php | 4 ++-- tests/phpunit/Rest/EndpointTestBase.php | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Control/SubmitControl.php b/src/Control/SubmitControl.php index 1f8022ac..f35088da 100644 --- a/src/Control/SubmitControl.php +++ b/src/Control/SubmitControl.php @@ -161,7 +161,7 @@ public function validateFieldInternal( string $field, $value, array $allValues, * @param HTMLForm|null $form * @return Message Error message (to be rendered via text()). */ - private function getDefaultValidationError( string $field, $value, HTMLForm $form = null ): Message { + private function getDefaultValidationError( string $field, $value, ?HTMLForm $form = null ): Message { $errorMessage = $this->msg( 'mwoauth-invalid-field-' . $field ); if ( !$errorMessage->isDisabled() ) { return $errorMessage; @@ -190,7 +190,7 @@ private function getDefaultValidationError( string $field, $value, HTMLForm $for * @return bool|ApiMessage * @phan-param string|callable(mixed,array):(bool|StatusValue) $validator */ - private function getValidationResult( $validator, $value, array $allValues, HTMLForm $form = null ) { + private function getValidationResult( $validator, $value, array $allValues, ?HTMLForm $form = null ) { if ( is_string( $validator ) ) { return preg_match( $validator, $value ?? '' ); } diff --git a/src/Repository/AccessTokenRepository.php b/src/Repository/AccessTokenRepository.php index 7350f114..e37dea25 100644 --- a/src/Repository/AccessTokenRepository.php +++ b/src/Repository/AccessTokenRepository.php @@ -24,7 +24,7 @@ class AccessTokenRepository extends DatabaseRepository implements AccessTokenRep * @param string|null $issuer */ public function __construct( - string $issuer = null + ?string $issuer = null ) { if ( !$issuer ) { // TODO: When the extension is converted to proper use of DI, diff --git a/src/SessionProvider.php b/src/SessionProvider.php index 4d2a0b5a..75cdb31c 100644 --- a/src/SessionProvider.php +++ b/src/SessionProvider.php @@ -335,7 +335,7 @@ public function getVaryHeaders() { * @param UserIdentity|null $userIdentity * @return array|null */ - private function getSessionData( UserIdentity $userIdentity = null ) { + private function getSessionData( ?UserIdentity $userIdentity = null ) { if ( $userIdentity ) { $user = User::newFromIdentity( $userIdentity ); $session = $user->getRequest()->getSession(); @@ -428,7 +428,7 @@ public function onRecentChange_save( $rc ) { * @param UserIdentity|null $userIdentity * @return int|null */ - protected function getPublicConsumerId( UserIdentity $userIdentity = null ) { + protected function getPublicConsumerId( ?UserIdentity $userIdentity = null ) { $data = $this->getSessionData( $userIdentity ); if ( $data && isset( $data['consumerId'] ) ) { return $data['consumerId']; diff --git a/tests/phpunit/Rest/EndpointTestBase.php b/tests/phpunit/Rest/EndpointTestBase.php index 09e69246..3007cdf2 100644 --- a/tests/phpunit/Rest/EndpointTestBase.php +++ b/tests/phpunit/Rest/EndpointTestBase.php @@ -62,8 +62,8 @@ abstract protected function newHandler(): Handler; public function testHandlerExecute( array $requestInfo = [], array $responseInfo = [], - callable $userCreateCallback = null, - callable $extraValidationCallback = null + ?callable $userCreateCallback = null, + ?callable $extraValidationCallback = null ) { if ( isset( $requestInfo['postParams'] ) ) { $requestInfo['method'] = 'POST';