Skip to content

Commit

Permalink
Use ?? instead of default value in getRawVal()
Browse files Browse the repository at this point in the history
In SpecialItemDisambiguation, this eliminates a Phan override because
Phan can now properly understand that $languageCode won’t be null \o/

Bug: T376245
Change-Id: I657fccbda103858df18a9e8e09ba15884b74875c
  • Loading branch information
lucaswerkmeister committed Oct 2, 2024
1 parent 27ddce7 commit 2c73d8e
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 7 deletions.
6 changes: 1 addition & 5 deletions repo/includes/Specials/SpecialItemDisambiguation.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,12 @@ public function execute( $subPage ) {
}

private function extractLanguageCode( WebRequest $request, array $subPageParts ): string {
$languageCode = $request->getRawVal(
'language',
$subPageParts[0] ?? ''
);
$languageCode = $request->getRawVal( 'language' ) ?? $subPageParts[0] ?? '';

if ( $languageCode === '' ) {
$languageCode = $this->getLanguage()->getCode();
}

// @phan-suppress-next-line PhanTypeMismatchReturnNullable False positive getRawVal not return null here
return $languageCode;
}

Expand Down
2 changes: 1 addition & 1 deletion repo/includes/Specials/SpecialModifyTerm.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ protected function processArguments( $subPage ) {
$request = $this->getRequest();
$parts = $subPage ? explode( '/', $subPage, 2 ) : [];

$this->languageCode = $request->getRawVal( 'language', $parts[1] ?? '' );
$this->languageCode = $request->getRawVal( 'language' ) ?? $parts[1] ?? '';

if ( $this->languageCode === '' ) {
$this->languageCode = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ private function extractInput( $subPage ) {
$request = $this->getRequest();

$parts = $subPage ? explode( '/', $subPage, 2 ) : [];
$this->languageCode = $request->getRawVal( 'language', $parts[1] ?? '' );
$this->languageCode = $request->getRawVal( 'language' ) ?? $parts[1] ?? '';

$label = $request->getVal( 'label', '' );
$this->label = $this->stringNormalizer->trimToNFC( $label );
Expand Down

0 comments on commit 2c73d8e

Please sign in to comment.