Skip to content

Commit

Permalink
Use explicit nullable type on parameter arguments
Browse files Browse the repository at this point in the history
Bug: T376276
Change-Id: I0413ac75ecc340a8e6844a351ddb838288cbb5b8
  • Loading branch information
reedy committed Oct 27, 2024
1 parent fa2072a commit ce0e5b6
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/Control/SubmitControl.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 ?? '' );
}
Expand Down
2 changes: 1 addition & 1 deletion src/Repository/AccessTokenRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/SessionProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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'];
Expand Down
4 changes: 2 additions & 2 deletions tests/phpunit/Rest/EndpointTestBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down

0 comments on commit ce0e5b6

Please sign in to comment.