Skip to content

Commit

Permalink
lib: Use null coalesce to simplify code in EntityDiff/ItemDiff
Browse files Browse the repository at this point in the history
Issue found by phan
Some of the lib/packages/ folder are currently excluded from analysis

Change-Id: I4cc503a5fabdfedbf273f5e738d972055535a2e8
  • Loading branch information
umherirrender authored and WMDE bot committed Jan 20, 2025
1 parent d41775d commit 2436d4a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/Diff/EntityDiff.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ protected function fixSubstructureDiff( array &$operations, $key ) {
* @return Diff
*/
public function getAliasesDiff() {
return isset( $this['aliases'] ) ? $this['aliases'] : new Diff( [], true );
return $this['aliases'] ?? new Diff( [], true );
}

/**
Expand All @@ -94,7 +94,7 @@ public function getAliasesDiff() {
* @return Diff
*/
public function getLabelsDiff() {
return isset( $this['label'] ) ? $this['label'] : new Diff( [], true );
return $this['label'] ?? new Diff( [], true );
}

/**
Expand All @@ -105,7 +105,7 @@ public function getLabelsDiff() {
* @return Diff
*/
public function getDescriptionsDiff() {
return isset( $this['description'] ) ? $this['description'] : new Diff( [], true );
return $this['description'] ?? new Diff( [], true );
}

/**
Expand All @@ -116,7 +116,7 @@ public function getDescriptionsDiff() {
* @return Diff
*/
public function getClaimsDiff() {
return isset( $this['claim'] ) ? $this['claim'] : new Diff( [], true );
return $this['claim'] ?? new Diff( [], true );
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Diff/ItemDiff.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function __construct( array $operations = [] ) {
* @return Diff
*/
public function getSiteLinkDiff() {
return isset( $this['links'] ) ? $this['links'] : new Diff( [], true );
return $this['links'] ?? new Diff( [], true );
}

/**
Expand Down

0 comments on commit 2436d4a

Please sign in to comment.