Merge "Simplify CategoryTree::capDepth"

This commit is contained in:
jenkins-bot 2021-08-24 09:30:11 +00:00 committed by Gerrit Code Review
commit 6cba244a94

View file

@ -802,7 +802,6 @@ class CategoryTree {
/** /**
* Internal function to cap depth * Internal function to cap depth
* @suppress PhanPluginDuplicateConditionalNullCoalescing until PHP7 is required
* @param string $mode * @param string $mode
* @param int $depth * @param int $depth
* @return int|mixed * @return int|mixed
@ -810,14 +809,14 @@ class CategoryTree {
public static function capDepth( $mode, $depth ) { public static function capDepth( $mode, $depth ) {
global $wgCategoryTreeMaxDepth; global $wgCategoryTreeMaxDepth;
if ( is_numeric( $depth ) ) { if ( !is_numeric( $depth ) ) {
$depth = intval( $depth );
} else {
return 1; return 1;
} }
$depth = intval( $depth );
if ( is_array( $wgCategoryTreeMaxDepth ) ) { if ( is_array( $wgCategoryTreeMaxDepth ) ) {
$max = isset( $wgCategoryTreeMaxDepth[$mode] ) ? $wgCategoryTreeMaxDepth[$mode] : 1; $max = $wgCategoryTreeMaxDepth[$mode] ?? 1;
} elseif ( is_numeric( $wgCategoryTreeMaxDepth ) ) { } elseif ( is_numeric( $wgCategoryTreeMaxDepth ) ) {
$max = $wgCategoryTreeMaxDepth; $max = $wgCategoryTreeMaxDepth;
} else { } else {